documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Scalar computation library
  496. */
  497. export class Scalar {
  498. /**
  499. * Two pi constants convenient for computation.
  500. */
  501. static TwoPi: number;
  502. /**
  503. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  504. * @param a number
  505. * @param b number
  506. * @param epsilon (default = 1.401298E-45)
  507. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  508. */
  509. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  510. /**
  511. * Returns a string : the upper case translation of the number i to hexadecimal.
  512. * @param i number
  513. * @returns the upper case translation of the number i to hexadecimal.
  514. */
  515. static ToHex(i: number): string;
  516. /**
  517. * Returns -1 if value is negative and +1 is value is positive.
  518. * @param value the value
  519. * @returns the value itself if it's equal to zero.
  520. */
  521. static Sign(value: number): number;
  522. /**
  523. * Returns the value itself if it's between min and max.
  524. * Returns min if the value is lower than min.
  525. * Returns max if the value is greater than max.
  526. * @param value the value to clmap
  527. * @param min the min value to clamp to (default: 0)
  528. * @param max the max value to clamp to (default: 1)
  529. * @returns the clamped value
  530. */
  531. static Clamp(value: number, min?: number, max?: number): number;
  532. /**
  533. * the log2 of value.
  534. * @param value the value to compute log2 of
  535. * @returns the log2 of value.
  536. */
  537. static Log2(value: number): number;
  538. /**
  539. * Loops the value, so that it is never larger than length and never smaller than 0.
  540. *
  541. * This is similar to the modulo operator but it works with floating point numbers.
  542. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  543. * With t = 5 and length = 2.5, the result would be 0.0.
  544. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  545. * @param value the value
  546. * @param length the length
  547. * @returns the looped value
  548. */
  549. static Repeat(value: number, length: number): number;
  550. /**
  551. * Normalize the value between 0.0 and 1.0 using min and max values
  552. * @param value value to normalize
  553. * @param min max to normalize between
  554. * @param max min to normalize between
  555. * @returns the normalized value
  556. */
  557. static Normalize(value: number, min: number, max: number): number;
  558. /**
  559. * Denormalize the value from 0.0 and 1.0 using min and max values
  560. * @param normalized value to denormalize
  561. * @param min max to denormalize between
  562. * @param max min to denormalize between
  563. * @returns the denormalized value
  564. */
  565. static Denormalize(normalized: number, min: number, max: number): number;
  566. /**
  567. * Calculates the shortest difference between two given angles given in degrees.
  568. * @param current current angle in degrees
  569. * @param target target angle in degrees
  570. * @returns the delta
  571. */
  572. static DeltaAngle(current: number, target: number): number;
  573. /**
  574. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  575. * @param tx value
  576. * @param length length
  577. * @returns The returned value will move back and forth between 0 and length
  578. */
  579. static PingPong(tx: number, length: number): number;
  580. /**
  581. * Interpolates between min and max with smoothing at the limits.
  582. *
  583. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  584. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  585. * @param from from
  586. * @param to to
  587. * @param tx value
  588. * @returns the smooth stepped value
  589. */
  590. static SmoothStep(from: number, to: number, tx: number): number;
  591. /**
  592. * Moves a value current towards target.
  593. *
  594. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  595. * Negative values of maxDelta pushes the value away from target.
  596. * @param current current value
  597. * @param target target value
  598. * @param maxDelta max distance to move
  599. * @returns resulting value
  600. */
  601. static MoveTowards(current: number, target: number, maxDelta: number): number;
  602. /**
  603. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  604. *
  605. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  606. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  607. * @param current current value
  608. * @param target target value
  609. * @param maxDelta max distance to move
  610. * @returns resulting angle
  611. */
  612. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  613. /**
  614. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  615. * @param start start value
  616. * @param end target value
  617. * @param amount amount to lerp between
  618. * @returns the lerped value
  619. */
  620. static Lerp(start: number, end: number, amount: number): number;
  621. /**
  622. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  623. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  624. * @param start start value
  625. * @param end target value
  626. * @param amount amount to lerp between
  627. * @returns the lerped value
  628. */
  629. static LerpAngle(start: number, end: number, amount: number): number;
  630. /**
  631. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  632. * @param a start value
  633. * @param b target value
  634. * @param value value between a and b
  635. * @returns the inverseLerp value
  636. */
  637. static InverseLerp(a: number, b: number, value: number): number;
  638. /**
  639. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  640. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  641. * @param value1 spline value
  642. * @param tangent1 spline value
  643. * @param value2 spline value
  644. * @param tangent2 spline value
  645. * @param amount input value
  646. * @returns hermite result
  647. */
  648. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  649. /**
  650. * Returns a random float number between and min and max values
  651. * @param min min value of random
  652. * @param max max value of random
  653. * @returns random value
  654. */
  655. static RandomRange(min: number, max: number): number;
  656. /**
  657. * This function returns percentage of a number in a given range.
  658. *
  659. * RangeToPercent(40,20,60) will return 0.5 (50%)
  660. * RangeToPercent(34,0,100) will return 0.34 (34%)
  661. * @param number to convert to percentage
  662. * @param min min range
  663. * @param max max range
  664. * @returns the percentage
  665. */
  666. static RangeToPercent(number: number, min: number, max: number): number;
  667. /**
  668. * This function returns number that corresponds to the percentage in a given range.
  669. *
  670. * PercentToRange(0.34,0,100) will return 34.
  671. * @param percent to convert to number
  672. * @param min min range
  673. * @param max max range
  674. * @returns the number
  675. */
  676. static PercentToRange(percent: number, min: number, max: number): number;
  677. /**
  678. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  679. * @param angle The angle to normalize in radian.
  680. * @return The converted angle.
  681. */
  682. static NormalizeRadians(angle: number): number;
  683. }
  684. }
  685. declare module BABYLON {
  686. /**
  687. * Constant used to convert a value to gamma space
  688. * @ignorenaming
  689. */
  690. export const ToGammaSpace: number;
  691. /**
  692. * Constant used to convert a value to linear space
  693. * @ignorenaming
  694. */
  695. export const ToLinearSpace = 2.2;
  696. /**
  697. * Constant used to define the minimal number value in Babylon.js
  698. * @ignorenaming
  699. */
  700. let Epsilon: number;
  701. }
  702. declare module BABYLON {
  703. /**
  704. * Class used to represent a viewport on screen
  705. */
  706. export class Viewport {
  707. /** viewport left coordinate */
  708. x: number;
  709. /** viewport top coordinate */
  710. y: number;
  711. /**viewport width */
  712. width: number;
  713. /** viewport height */
  714. height: number;
  715. /**
  716. * Creates a Viewport object located at (x, y) and sized (width, height)
  717. * @param x defines viewport left coordinate
  718. * @param y defines viewport top coordinate
  719. * @param width defines the viewport width
  720. * @param height defines the viewport height
  721. */
  722. constructor(
  723. /** viewport left coordinate */
  724. x: number,
  725. /** viewport top coordinate */
  726. y: number,
  727. /**viewport width */
  728. width: number,
  729. /** viewport height */
  730. height: number);
  731. /**
  732. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  733. * @param renderWidth defines the rendering width
  734. * @param renderHeight defines the rendering height
  735. * @returns a new Viewport
  736. */
  737. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  738. /**
  739. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  740. * @param renderWidth defines the rendering width
  741. * @param renderHeight defines the rendering height
  742. * @param ref defines the target viewport
  743. * @returns the current viewport
  744. */
  745. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  746. /**
  747. * Returns a new Viewport copied from the current one
  748. * @returns a new Viewport
  749. */
  750. clone(): Viewport;
  751. }
  752. }
  753. declare module BABYLON {
  754. /**
  755. * Class containing a set of static utilities functions for arrays.
  756. */
  757. export class ArrayTools {
  758. /**
  759. * Returns an array of the given size filled with element built from the given constructor and the paramters
  760. * @param size the number of element to construct and put in the array
  761. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  762. * @returns a new array filled with new objects
  763. */
  764. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  765. }
  766. }
  767. declare module BABYLON {
  768. /**
  769. * @hidden
  770. */
  771. export interface IColor4Like {
  772. r: float;
  773. g: float;
  774. b: float;
  775. a: float;
  776. }
  777. /**
  778. * @hidden
  779. */
  780. export interface IColor3Like {
  781. r: float;
  782. g: float;
  783. b: float;
  784. }
  785. /**
  786. * @hidden
  787. */
  788. export interface IVector4Like {
  789. x: float;
  790. y: float;
  791. z: float;
  792. w: float;
  793. }
  794. /**
  795. * @hidden
  796. */
  797. export interface IVector3Like {
  798. x: float;
  799. y: float;
  800. z: float;
  801. }
  802. /**
  803. * @hidden
  804. */
  805. export interface IVector2Like {
  806. x: float;
  807. y: float;
  808. }
  809. /**
  810. * @hidden
  811. */
  812. export interface IMatrixLike {
  813. toArray(): DeepImmutable<Float32Array>;
  814. updateFlag: int;
  815. }
  816. /**
  817. * @hidden
  818. */
  819. export interface IViewportLike {
  820. x: float;
  821. y: float;
  822. width: float;
  823. height: float;
  824. }
  825. /**
  826. * @hidden
  827. */
  828. export interface IPlaneLike {
  829. normal: IVector3Like;
  830. d: float;
  831. normalize(): void;
  832. }
  833. }
  834. declare module BABYLON {
  835. /**
  836. * Class representing a vector containing 2 coordinates
  837. */
  838. export class Vector2 {
  839. /** defines the first coordinate */
  840. x: number;
  841. /** defines the second coordinate */
  842. y: number;
  843. /**
  844. * Creates a new Vector2 from the given x and y coordinates
  845. * @param x defines the first coordinate
  846. * @param y defines the second coordinate
  847. */
  848. constructor(
  849. /** defines the first coordinate */
  850. x?: number,
  851. /** defines the second coordinate */
  852. y?: number);
  853. /**
  854. * Gets a string with the Vector2 coordinates
  855. * @returns a string with the Vector2 coordinates
  856. */
  857. toString(): string;
  858. /**
  859. * Gets class name
  860. * @returns the string "Vector2"
  861. */
  862. getClassName(): string;
  863. /**
  864. * Gets current vector hash code
  865. * @returns the Vector2 hash code as a number
  866. */
  867. getHashCode(): number;
  868. /**
  869. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  870. * @param array defines the source array
  871. * @param index defines the offset in source array
  872. * @returns the current Vector2
  873. */
  874. toArray(array: FloatArray, index?: number): Vector2;
  875. /**
  876. * Copy the current vector to an array
  877. * @returns a new array with 2 elements: the Vector2 coordinates.
  878. */
  879. asArray(): number[];
  880. /**
  881. * Sets the Vector2 coordinates with the given Vector2 coordinates
  882. * @param source defines the source Vector2
  883. * @returns the current updated Vector2
  884. */
  885. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  886. /**
  887. * Sets the Vector2 coordinates with the given floats
  888. * @param x defines the first coordinate
  889. * @param y defines the second coordinate
  890. * @returns the current updated Vector2
  891. */
  892. copyFromFloats(x: number, y: number): Vector2;
  893. /**
  894. * Sets the Vector2 coordinates with the given floats
  895. * @param x defines the first coordinate
  896. * @param y defines the second coordinate
  897. * @returns the current updated Vector2
  898. */
  899. set(x: number, y: number): Vector2;
  900. /**
  901. * Add another vector with the current one
  902. * @param otherVector defines the other vector
  903. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  904. */
  905. add(otherVector: DeepImmutable<Vector2>): Vector2;
  906. /**
  907. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  908. * @param otherVector defines the other vector
  909. * @param result defines the target vector
  910. * @returns the unmodified current Vector2
  911. */
  912. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  913. /**
  914. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  915. * @param otherVector defines the other vector
  916. * @returns the current updated Vector2
  917. */
  918. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  921. * @param otherVector defines the other vector
  922. * @returns a new Vector2
  923. */
  924. addVector3(otherVector: Vector3): Vector2;
  925. /**
  926. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  927. * @param otherVector defines the other vector
  928. * @returns a new Vector2
  929. */
  930. subtract(otherVector: Vector2): Vector2;
  931. /**
  932. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  933. * @param otherVector defines the other vector
  934. * @param result defines the target vector
  935. * @returns the unmodified current Vector2
  936. */
  937. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  938. /**
  939. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  940. * @param otherVector defines the other vector
  941. * @returns the current updated Vector2
  942. */
  943. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  944. /**
  945. * Multiplies in place the current Vector2 coordinates by the given ones
  946. * @param otherVector defines the other vector
  947. * @returns the current updated Vector2
  948. */
  949. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  950. /**
  951. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  952. * @param otherVector defines the other vector
  953. * @returns a new Vector2
  954. */
  955. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  956. /**
  957. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  958. * @param otherVector defines the other vector
  959. * @param result defines the target vector
  960. * @returns the unmodified current Vector2
  961. */
  962. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  963. /**
  964. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  965. * @param x defines the first coordinate
  966. * @param y defines the second coordinate
  967. * @returns a new Vector2
  968. */
  969. multiplyByFloats(x: number, y: number): Vector2;
  970. /**
  971. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  972. * @param otherVector defines the other vector
  973. * @returns a new Vector2
  974. */
  975. divide(otherVector: Vector2): Vector2;
  976. /**
  977. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  978. * @param otherVector defines the other vector
  979. * @param result defines the target vector
  980. * @returns the unmodified current Vector2
  981. */
  982. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  983. /**
  984. * Divides the current Vector2 coordinates by the given ones
  985. * @param otherVector defines the other vector
  986. * @returns the current updated Vector2
  987. */
  988. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  989. /**
  990. * Gets a new Vector2 with current Vector2 negated coordinates
  991. * @returns a new Vector2
  992. */
  993. negate(): Vector2;
  994. /**
  995. * Multiply the Vector2 coordinates by scale
  996. * @param scale defines the scaling factor
  997. * @returns the current updated Vector2
  998. */
  999. scaleInPlace(scale: number): Vector2;
  1000. /**
  1001. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1002. * @param scale defines the scaling factor
  1003. * @returns a new Vector2
  1004. */
  1005. scale(scale: number): Vector2;
  1006. /**
  1007. * Scale the current Vector2 values by a factor to a given Vector2
  1008. * @param scale defines the scale factor
  1009. * @param result defines the Vector2 object where to store the result
  1010. * @returns the unmodified current Vector2
  1011. */
  1012. scaleToRef(scale: number, result: Vector2): Vector2;
  1013. /**
  1014. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1015. * @param scale defines the scale factor
  1016. * @param result defines the Vector2 object where to store the result
  1017. * @returns the unmodified current Vector2
  1018. */
  1019. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1020. /**
  1021. * Gets a boolean if two vectors are equals
  1022. * @param otherVector defines the other vector
  1023. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1024. */
  1025. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1026. /**
  1027. * Gets a boolean if two vectors are equals (using an epsilon value)
  1028. * @param otherVector defines the other vector
  1029. * @param epsilon defines the minimal distance to consider equality
  1030. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1031. */
  1032. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. floor(): Vector2;
  1038. /**
  1039. * Gets a new Vector2 from current Vector2 floored values
  1040. * @returns a new Vector2
  1041. */
  1042. fract(): Vector2;
  1043. /**
  1044. * Gets the length of the vector
  1045. * @returns the vector length (float)
  1046. */
  1047. length(): number;
  1048. /**
  1049. * Gets the vector squared length
  1050. * @returns the vector squared length (float)
  1051. */
  1052. lengthSquared(): number;
  1053. /**
  1054. * Normalize the vector
  1055. * @returns the current updated Vector2
  1056. */
  1057. normalize(): Vector2;
  1058. /**
  1059. * Gets a new Vector2 copied from the Vector2
  1060. * @returns a new Vector2
  1061. */
  1062. clone(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(0, 0)
  1065. * @returns a new Vector2
  1066. */
  1067. static Zero(): Vector2;
  1068. /**
  1069. * Gets a new Vector2(1, 1)
  1070. * @returns a new Vector2
  1071. */
  1072. static One(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 set from the given index element of the given array
  1075. * @param array defines the data source
  1076. * @param offset defines the offset in the data source
  1077. * @returns a new Vector2
  1078. */
  1079. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1080. /**
  1081. * Sets "result" from the given index element of the given array
  1082. * @param array defines the data source
  1083. * @param offset defines the offset in the data source
  1084. * @param result defines the target vector
  1085. */
  1086. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1087. /**
  1088. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1089. * @param value1 defines 1st point of control
  1090. * @param value2 defines 2nd point of control
  1091. * @param value3 defines 3rd point of control
  1092. * @param value4 defines 4th point of control
  1093. * @param amount defines the interpolation factor
  1094. * @returns a new Vector2
  1095. */
  1096. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1097. /**
  1098. * 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".
  1099. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1100. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1101. * @param value defines the value to clamp
  1102. * @param min defines the lower limit
  1103. * @param max defines the upper limit
  1104. * @returns a new Vector2
  1105. */
  1106. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1107. /**
  1108. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1109. * @param value1 defines the 1st control point
  1110. * @param tangent1 defines the outgoing tangent
  1111. * @param value2 defines the 2nd control point
  1112. * @param tangent2 defines the incoming tangent
  1113. * @param amount defines the interpolation factor
  1114. * @returns a new Vector2
  1115. */
  1116. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1117. /**
  1118. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1119. * @param start defines the start vector
  1120. * @param end defines the end vector
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Gets the dot product of the vector "left" and the vector "right"
  1127. * @param left defines first vector
  1128. * @param right defines second vector
  1129. * @returns the dot product (float)
  1130. */
  1131. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1132. /**
  1133. * Returns a new Vector2 equal to the normalized given vector
  1134. * @param vector defines the vector to normalize
  1135. * @returns a new Vector2
  1136. */
  1137. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1138. /**
  1139. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1140. * @param left defines 1st vector
  1141. * @param right defines 2nd vector
  1142. * @returns a new Vector2
  1143. */
  1144. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1145. /**
  1146. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1147. * @param left defines 1st vector
  1148. * @param right defines 2nd vector
  1149. * @returns a new Vector2
  1150. */
  1151. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1152. /**
  1153. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1154. * @param vector defines the vector to transform
  1155. * @param transformation defines the matrix to apply
  1156. * @returns a new Vector2
  1157. */
  1158. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1159. /**
  1160. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1161. * @param vector defines the vector to transform
  1162. * @param transformation defines the matrix to apply
  1163. * @param result defines the target vector
  1164. */
  1165. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1166. /**
  1167. * Determines if a given vector is included in a triangle
  1168. * @param p defines the vector to test
  1169. * @param p0 defines 1st triangle point
  1170. * @param p1 defines 2nd triangle point
  1171. * @param p2 defines 3rd triangle point
  1172. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1173. */
  1174. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1175. /**
  1176. * Gets the distance between the vectors "value1" and "value2"
  1177. * @param value1 defines first vector
  1178. * @param value2 defines second vector
  1179. * @returns the distance between vectors
  1180. */
  1181. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1182. /**
  1183. * Returns the squared distance between the vectors "value1" and "value2"
  1184. * @param value1 defines first vector
  1185. * @param value2 defines second vector
  1186. * @returns the squared distance between vectors
  1187. */
  1188. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1189. /**
  1190. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1191. * @param value1 defines first vector
  1192. * @param value2 defines second vector
  1193. * @returns a new Vector2
  1194. */
  1195. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1196. /**
  1197. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1198. * @param p defines the middle point
  1199. * @param segA defines one point of the segment
  1200. * @param segB defines the other point of the segment
  1201. * @returns the shortest distance
  1202. */
  1203. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1204. }
  1205. /**
  1206. * Classed used to store (x,y,z) vector representation
  1207. * A Vector3 is the main object used in 3D geometry
  1208. * It can represent etiher the coordinates of a point the space, either a direction
  1209. * Reminder: js uses a left handed forward facing system
  1210. */
  1211. export class Vector3 {
  1212. /**
  1213. * Defines the first coordinates (on X axis)
  1214. */
  1215. x: number;
  1216. /**
  1217. * Defines the second coordinates (on Y axis)
  1218. */
  1219. y: number;
  1220. /**
  1221. * Defines the third coordinates (on Z axis)
  1222. */
  1223. z: number;
  1224. private static _UpReadOnly;
  1225. private static _ZeroReadOnly;
  1226. /**
  1227. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1228. * @param x defines the first coordinates (on X axis)
  1229. * @param y defines the second coordinates (on Y axis)
  1230. * @param z defines the third coordinates (on Z axis)
  1231. */
  1232. constructor(
  1233. /**
  1234. * Defines the first coordinates (on X axis)
  1235. */
  1236. x?: number,
  1237. /**
  1238. * Defines the second coordinates (on Y axis)
  1239. */
  1240. y?: number,
  1241. /**
  1242. * Defines the third coordinates (on Z axis)
  1243. */
  1244. z?: number);
  1245. /**
  1246. * Creates a string representation of the Vector3
  1247. * @returns a string with the Vector3 coordinates.
  1248. */
  1249. toString(): string;
  1250. /**
  1251. * Gets the class name
  1252. * @returns the string "Vector3"
  1253. */
  1254. getClassName(): string;
  1255. /**
  1256. * Creates the Vector3 hash code
  1257. * @returns a number which tends to be unique between Vector3 instances
  1258. */
  1259. getHashCode(): number;
  1260. /**
  1261. * Creates an array containing three elements : the coordinates of the Vector3
  1262. * @returns a new array of numbers
  1263. */
  1264. asArray(): number[];
  1265. /**
  1266. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1267. * @param array defines the destination array
  1268. * @param index defines the offset in the destination array
  1269. * @returns the current Vector3
  1270. */
  1271. toArray(array: FloatArray, index?: number): Vector3;
  1272. /**
  1273. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1274. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1275. */
  1276. toQuaternion(): Quaternion;
  1277. /**
  1278. * Adds the given vector to the current Vector3
  1279. * @param otherVector defines the second operand
  1280. * @returns the current updated Vector3
  1281. */
  1282. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1283. /**
  1284. * Adds the given coordinates to the current Vector3
  1285. * @param x defines the x coordinate of the operand
  1286. * @param y defines the y coordinate of the operand
  1287. * @param z defines the z coordinate of the operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1291. /**
  1292. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1293. * @param otherVector defines the second operand
  1294. * @returns the resulting Vector3
  1295. */
  1296. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1297. /**
  1298. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1299. * @param otherVector defines the second operand
  1300. * @param result defines the Vector3 object where to store the result
  1301. * @returns the current Vector3
  1302. */
  1303. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1304. /**
  1305. * Subtract the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the current updated Vector3
  1308. */
  1309. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1312. * @param otherVector defines the second operand
  1313. * @returns the resulting Vector3
  1314. */
  1315. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1316. /**
  1317. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1318. * @param otherVector defines the second operand
  1319. * @param result defines the Vector3 object where to store the result
  1320. * @returns the current Vector3
  1321. */
  1322. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1323. /**
  1324. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1325. * @param x defines the x coordinate of the operand
  1326. * @param y defines the y coordinate of the operand
  1327. * @param z defines the z coordinate of the operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1331. /**
  1332. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @param result defines the Vector3 object where to store the result
  1337. * @returns the current Vector3
  1338. */
  1339. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1340. /**
  1341. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1342. * @returns a new Vector3
  1343. */
  1344. negate(): Vector3;
  1345. /**
  1346. * Multiplies the Vector3 coordinates by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns the current updated Vector3
  1349. */
  1350. scaleInPlace(scale: number): Vector3;
  1351. /**
  1352. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1353. * @param scale defines the multiplier factor
  1354. * @returns a new Vector3
  1355. */
  1356. scale(scale: number): Vector3;
  1357. /**
  1358. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1359. * @param scale defines the multiplier factor
  1360. * @param result defines the Vector3 object where to store the result
  1361. * @returns the current Vector3
  1362. */
  1363. scaleToRef(scale: number, result: Vector3): Vector3;
  1364. /**
  1365. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1366. * @param scale defines the scale factor
  1367. * @param result defines the Vector3 object where to store the result
  1368. * @returns the unmodified current Vector3
  1369. */
  1370. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1373. * @param otherVector defines the second operand
  1374. * @returns true if both vectors are equals
  1375. */
  1376. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1377. /**
  1378. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1379. * @param otherVector defines the second operand
  1380. * @param epsilon defines the minimal distance to define values as equals
  1381. * @returns true if both vectors are distant less than epsilon
  1382. */
  1383. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1384. /**
  1385. * Returns true if the current Vector3 coordinates equals the given floats
  1386. * @param x defines the x coordinate of the operand
  1387. * @param y defines the y coordinate of the operand
  1388. * @param z defines the z coordinate of the operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equalsToFloats(x: number, y: number, z: number): boolean;
  1392. /**
  1393. * Multiplies the current Vector3 coordinates by the given ones
  1394. * @param otherVector defines the second operand
  1395. * @returns the current updated Vector3
  1396. */
  1397. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1400. * @param otherVector defines the second operand
  1401. * @returns the new Vector3
  1402. */
  1403. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1404. /**
  1405. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1406. * @param otherVector defines the second operand
  1407. * @param result defines the Vector3 object where to store the result
  1408. * @returns the current Vector3
  1409. */
  1410. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1411. /**
  1412. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1413. * @param x defines the x coordinate of the operand
  1414. * @param y defines the y coordinate of the operand
  1415. * @param z defines the z coordinate of the operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1421. * @param otherVector defines the second operand
  1422. * @returns the new Vector3
  1423. */
  1424. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1425. /**
  1426. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1427. * @param otherVector defines the second operand
  1428. * @param result defines the Vector3 object where to store the result
  1429. * @returns the current Vector3
  1430. */
  1431. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1432. /**
  1433. * Divides the current Vector3 coordinates by the given ones.
  1434. * @param otherVector defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. divideInPlace(otherVector: Vector3): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1446. * @param other defines the second operand
  1447. * @returns the current updated Vector3
  1448. */
  1449. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1450. /**
  1451. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1452. * @param x defines the x coordinate of the operand
  1453. * @param y defines the y coordinate of the operand
  1454. * @param z defines the z coordinate of the operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1468. * Check if is non uniform within a certain amount of decimal places to account for this
  1469. * @param epsilon the amount the values can differ
  1470. * @returns if the the vector is non uniform to a certain number of decimal places
  1471. */
  1472. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1473. /**
  1474. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1475. */
  1476. readonly isNonUniform: boolean;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. floor(): Vector3;
  1482. /**
  1483. * Gets a new Vector3 from current Vector3 floored values
  1484. * @returns a new Vector3
  1485. */
  1486. fract(): Vector3;
  1487. /**
  1488. * Gets the length of the Vector3
  1489. * @returns the length of the Vector3
  1490. */
  1491. length(): number;
  1492. /**
  1493. * Gets the squared length of the Vector3
  1494. * @returns squared length of the Vector3
  1495. */
  1496. lengthSquared(): number;
  1497. /**
  1498. * Normalize the current Vector3.
  1499. * Please note that this is an in place operation.
  1500. * @returns the current updated Vector3
  1501. */
  1502. normalize(): Vector3;
  1503. /**
  1504. * Reorders the x y z properties of the vector in place
  1505. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1506. * @returns the current updated vector
  1507. */
  1508. reorderInPlace(order: string): this;
  1509. /**
  1510. * Rotates the vector around 0,0,0 by a quaternion
  1511. * @param quaternion the rotation quaternion
  1512. * @param result vector to store the result
  1513. * @returns the resulting vector
  1514. */
  1515. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1516. /**
  1517. * Rotates a vector around a given point
  1518. * @param quaternion the rotation quaternion
  1519. * @param point the point to rotate around
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1524. /**
  1525. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1526. * The cross product is then orthogonal to both current and "other"
  1527. * @param other defines the right operand
  1528. * @returns the cross product
  1529. */
  1530. cross(other: Vector3): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 with the given input length.
  1533. * Please note that this is an in place operation.
  1534. * @param len the length of the vector
  1535. * @returns the current updated Vector3
  1536. */
  1537. normalizeFromLength(len: number): Vector3;
  1538. /**
  1539. * Normalize the current Vector3 to a new vector
  1540. * @returns the new Vector3
  1541. */
  1542. normalizeToNew(): Vector3;
  1543. /**
  1544. * Normalize the current Vector3 to the reference
  1545. * @param reference define the Vector3 to update
  1546. * @returns the updated Vector3
  1547. */
  1548. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Creates a new Vector3 copied from the current Vector3
  1551. * @returns the new Vector3
  1552. */
  1553. clone(): Vector3;
  1554. /**
  1555. * Copies the given vector coordinates to the current Vector3 ones
  1556. * @param source defines the source Vector3
  1557. * @returns the current updated Vector3
  1558. */
  1559. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1560. /**
  1561. * Copies the given floats to the current Vector3 coordinates
  1562. * @param x defines the x coordinate of the operand
  1563. * @param y defines the y coordinate of the operand
  1564. * @param z defines the z coordinate of the operand
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFromFloats(x: number, y: number, z: number): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. set(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given float to the current Vector3 coordinates
  1578. * @param v defines the x, y and z coordinates of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. setAll(v: number): Vector3;
  1582. /**
  1583. * Get the clip factor between two vectors
  1584. * @param vector0 defines the first operand
  1585. * @param vector1 defines the second operand
  1586. * @param axis defines the axis to use
  1587. * @param size defines the size along the axis
  1588. * @returns the clip factor
  1589. */
  1590. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1591. /**
  1592. * Get angle between two vectors
  1593. * @param vector0 angle between vector0 and vector1
  1594. * @param vector1 angle between vector0 and vector1
  1595. * @param normal direction of the normal
  1596. * @return the angle between vector0 and vector1
  1597. */
  1598. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1599. /**
  1600. * Returns a new Vector3 set from the index "offset" of the given array
  1601. * @param array defines the source array
  1602. * @param offset defines the offset in the source array
  1603. * @returns the new Vector3
  1604. */
  1605. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1606. /**
  1607. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1608. * This function is deprecated. Use FromArray instead
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1614. /**
  1615. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1616. * @param array defines the source array
  1617. * @param offset defines the offset in the source array
  1618. * @param result defines the Vector3 where to store the result
  1619. */
  1620. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1621. /**
  1622. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1623. * This function is deprecated. Use FromArrayToRef instead.
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the given floats.
  1631. * @param x defines the x coordinate of the source
  1632. * @param y defines the y coordinate of the source
  1633. * @param z defines the z coordinate of the source
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1637. /**
  1638. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1639. * @returns a new empty Vector3
  1640. */
  1641. static Zero(): Vector3;
  1642. /**
  1643. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1644. * @returns a new unit Vector3
  1645. */
  1646. static One(): Vector3;
  1647. /**
  1648. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1649. * @returns a new up Vector3
  1650. */
  1651. static Up(): Vector3;
  1652. /**
  1653. * Gets a up Vector3 that must not be updated
  1654. */
  1655. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1656. /**
  1657. * Gets a zero Vector3 that must not be updated
  1658. */
  1659. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1660. /**
  1661. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1662. * @returns a new down Vector3
  1663. */
  1664. static Down(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1667. * @returns a new forward Vector3
  1668. */
  1669. static Forward(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1672. * @returns a new forward Vector3
  1673. */
  1674. static Backward(): Vector3;
  1675. /**
  1676. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1677. * @returns a new right Vector3
  1678. */
  1679. static Right(): Vector3;
  1680. /**
  1681. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1682. * @returns a new left Vector3
  1683. */
  1684. static Left(): Vector3;
  1685. /**
  1686. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1687. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1688. * @param vector defines the Vector3 to transform
  1689. * @param transformation defines the transformation matrix
  1690. * @returns the transformed Vector3
  1691. */
  1692. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1693. /**
  1694. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @param result defines the Vector3 where to store the result
  1699. */
  1700. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1703. * This method computes tranformed coordinates only, not transformed direction vectors
  1704. * @param x define the x coordinate of the source vector
  1705. * @param y define the y coordinate of the source vector
  1706. * @param z define the z coordinate of the source vector
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param vector defines the Vector3 to transform
  1715. * @param transformation defines the transformation matrix
  1716. * @returns the new Vector3
  1717. */
  1718. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1719. /**
  1720. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @param result defines the Vector3 where to store the result
  1725. */
  1726. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param x define the x coordinate of the source vector
  1731. * @param y define the y coordinate of the source vector
  1732. * @param z define the z coordinate of the source vector
  1733. * @param transformation defines the transformation matrix
  1734. * @param result defines the Vector3 where to store the result
  1735. */
  1736. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1737. /**
  1738. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1739. * @param value1 defines the first control point
  1740. * @param value2 defines the second control point
  1741. * @param value3 defines the third control point
  1742. * @param value4 defines the fourth control point
  1743. * @param amount defines the amount on the spline to use
  1744. * @returns the new Vector3
  1745. */
  1746. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1747. /**
  1748. * 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"
  1749. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1750. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1751. * @param value defines the current value
  1752. * @param min defines the lower range value
  1753. * @param max defines the upper range value
  1754. * @returns the new Vector3
  1755. */
  1756. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1757. /**
  1758. * 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"
  1759. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1760. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1761. * @param value defines the current value
  1762. * @param min defines the lower range value
  1763. * @param max defines the upper range value
  1764. * @param result defines the Vector3 where to store the result
  1765. */
  1766. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1767. /**
  1768. * Checks if a given vector is inside a specific range
  1769. * @param v defines the vector to test
  1770. * @param min defines the minimum range
  1771. * @param max defines the maximum range
  1772. */
  1773. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1774. /**
  1775. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1776. * @param value1 defines the first control point
  1777. * @param tangent1 defines the first tangent vector
  1778. * @param value2 defines the second control point
  1779. * @param tangent2 defines the second tangent vector
  1780. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1781. * @returns the new Vector3
  1782. */
  1783. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1784. /**
  1785. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1786. * @param start defines the start value
  1787. * @param end defines the end value
  1788. * @param amount max defines amount between both (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1800. /**
  1801. * Returns the dot product (float) between the vectors "left" and "right"
  1802. * @param left defines the left operand
  1803. * @param right defines the right operand
  1804. * @returns the dot product
  1805. */
  1806. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1807. /**
  1808. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1809. * The cross product is then orthogonal to both "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the cross product
  1813. */
  1814. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1815. /**
  1816. * Sets the given vector "result" with the cross product of "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @param result defines the Vector3 where to store the result
  1821. */
  1822. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1823. /**
  1824. * Returns a new Vector3 as the normalization of the given vector
  1825. * @param vector defines the Vector3 to normalize
  1826. * @returns the new Vector3
  1827. */
  1828. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Sets the given vector "result" with the normalization of the given first vector
  1831. * @param vector defines the Vector3 to normalize
  1832. * @param result defines the Vector3 where to store the result
  1833. */
  1834. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1835. /**
  1836. * Project a Vector3 onto screen space
  1837. * @param vector defines the Vector3 to project
  1838. * @param world defines the world matrix to use
  1839. * @param transform defines the transform (view x projection) matrix to use
  1840. * @param viewport defines the screen viewport to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1844. /** @hidden */
  1845. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1846. /**
  1847. * Unproject from screen space to object space
  1848. * @param source defines the screen space Vector3 to use
  1849. * @param viewportWidth defines the current width of the viewport
  1850. * @param viewportHeight defines the current height of the viewport
  1851. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1852. * @param transform defines the transform (view x projection) matrix to use
  1853. * @returns the new Vector3
  1854. */
  1855. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param source defines the screen space Vector3 to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @returns the new Vector3
  1865. */
  1866. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1867. /**
  1868. * Unproject from screen space to object space
  1869. * @param source defines the screen space Vector3 to use
  1870. * @param viewportWidth defines the current width of the viewport
  1871. * @param viewportHeight defines the current height of the viewport
  1872. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1873. * @param view defines the view matrix to use
  1874. * @param projection defines the projection matrix to use
  1875. * @param result defines the Vector3 where to store the result
  1876. */
  1877. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1878. /**
  1879. * Unproject from screen space to object space
  1880. * @param sourceX defines the screen space x coordinate to use
  1881. * @param sourceY defines the screen space y coordinate to use
  1882. * @param sourceZ defines the screen space z coordinate to use
  1883. * @param viewportWidth defines the current width of the viewport
  1884. * @param viewportHeight defines the current height of the viewport
  1885. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1886. * @param view defines the view matrix to use
  1887. * @param projection defines the projection matrix to use
  1888. * @param result defines the Vector3 where to store the result
  1889. */
  1890. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1891. /**
  1892. * Gets the minimal coordinate values between two Vector3
  1893. * @param left defines the first operand
  1894. * @param right defines the second operand
  1895. * @returns the new Vector3
  1896. */
  1897. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1898. /**
  1899. * Gets the maximal coordinate values between two Vector3
  1900. * @param left defines the first operand
  1901. * @param right defines the second operand
  1902. * @returns the new Vector3
  1903. */
  1904. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1905. /**
  1906. * Returns the distance between the vectors "value1" and "value2"
  1907. * @param value1 defines the first operand
  1908. * @param value2 defines the second operand
  1909. * @returns the distance
  1910. */
  1911. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1912. /**
  1913. * Returns the squared distance between the vectors "value1" and "value2"
  1914. * @param value1 defines the first operand
  1915. * @param value2 defines the second operand
  1916. * @returns the squared distance
  1917. */
  1918. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1919. /**
  1920. * Returns a new Vector3 located at the center between "value1" and "value2"
  1921. * @param value1 defines the first operand
  1922. * @param value2 defines the second operand
  1923. * @returns the new Vector3
  1924. */
  1925. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1926. /**
  1927. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1928. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1929. * to something in order to rotate it from its local system to the given target system
  1930. * Note: axis1, axis2 and axis3 are normalized during this operation
  1931. * @param axis1 defines the first axis
  1932. * @param axis2 defines the second axis
  1933. * @param axis3 defines the third axis
  1934. * @returns a new Vector3
  1935. */
  1936. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1937. /**
  1938. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1939. * @param axis1 defines the first axis
  1940. * @param axis2 defines the second axis
  1941. * @param axis3 defines the third axis
  1942. * @param ref defines the Vector3 where to store the result
  1943. */
  1944. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1945. }
  1946. /**
  1947. * Vector4 class created for EulerAngle class conversion to Quaternion
  1948. */
  1949. export class Vector4 {
  1950. /** x value of the vector */
  1951. x: number;
  1952. /** y value of the vector */
  1953. y: number;
  1954. /** z value of the vector */
  1955. z: number;
  1956. /** w value of the vector */
  1957. w: number;
  1958. /**
  1959. * Creates a Vector4 object from the given floats.
  1960. * @param x x value of the vector
  1961. * @param y y value of the vector
  1962. * @param z z value of the vector
  1963. * @param w w value of the vector
  1964. */
  1965. constructor(
  1966. /** x value of the vector */
  1967. x: number,
  1968. /** y value of the vector */
  1969. y: number,
  1970. /** z value of the vector */
  1971. z: number,
  1972. /** w value of the vector */
  1973. w: number);
  1974. /**
  1975. * Returns the string with the Vector4 coordinates.
  1976. * @returns a string containing all the vector values
  1977. */
  1978. toString(): string;
  1979. /**
  1980. * Returns the string "Vector4".
  1981. * @returns "Vector4"
  1982. */
  1983. getClassName(): string;
  1984. /**
  1985. * Returns the Vector4 hash code.
  1986. * @returns a unique hash code
  1987. */
  1988. getHashCode(): number;
  1989. /**
  1990. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1991. * @returns the resulting array
  1992. */
  1993. asArray(): number[];
  1994. /**
  1995. * Populates the given array from the given index with the Vector4 coordinates.
  1996. * @param array array to populate
  1997. * @param index index of the array to start at (default: 0)
  1998. * @returns the Vector4.
  1999. */
  2000. toArray(array: FloatArray, index?: number): Vector4;
  2001. /**
  2002. * Adds the given vector to the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the updated Vector4.
  2005. */
  2006. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2009. * @param otherVector the vector to add
  2010. * @returns the resulting vector
  2011. */
  2012. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2013. /**
  2014. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2015. * @param otherVector the vector to add
  2016. * @param result the vector to store the result
  2017. * @returns the current Vector4.
  2018. */
  2019. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2020. /**
  2021. * Subtract in place the given vector from the current Vector4.
  2022. * @param otherVector the vector to subtract
  2023. * @returns the updated Vector4.
  2024. */
  2025. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2026. /**
  2027. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2028. * @param otherVector the vector to add
  2029. * @returns the new vector with the result
  2030. */
  2031. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2032. /**
  2033. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2034. * @param otherVector the vector to subtract
  2035. * @param result the vector to store the result
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2041. */
  2042. /**
  2043. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2044. * @param x value to subtract
  2045. * @param y value to subtract
  2046. * @param z value to subtract
  2047. * @param w value to subtract
  2048. * @returns new vector containing the result
  2049. */
  2050. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2051. /**
  2052. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2053. * @param x value to subtract
  2054. * @param y value to subtract
  2055. * @param z value to subtract
  2056. * @param w value to subtract
  2057. * @param result the vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2061. /**
  2062. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2063. * @returns a new vector with the negated values
  2064. */
  2065. negate(): Vector4;
  2066. /**
  2067. * Multiplies the current Vector4 coordinates by scale (float).
  2068. * @param scale the number to scale with
  2069. * @returns the updated Vector4.
  2070. */
  2071. scaleInPlace(scale: number): Vector4;
  2072. /**
  2073. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2074. * @param scale the number to scale with
  2075. * @returns a new vector with the result
  2076. */
  2077. scale(scale: number): Vector4;
  2078. /**
  2079. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2080. * @param scale the number to scale with
  2081. * @param result a vector to store the result in
  2082. * @returns the current Vector4.
  2083. */
  2084. scaleToRef(scale: number, result: Vector4): Vector4;
  2085. /**
  2086. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2087. * @param scale defines the scale factor
  2088. * @param result defines the Vector4 object where to store the result
  2089. * @returns the unmodified current Vector4
  2090. */
  2091. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2092. /**
  2093. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2094. * @param otherVector the vector to compare against
  2095. * @returns true if they are equal
  2096. */
  2097. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2098. /**
  2099. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2100. * @param otherVector vector to compare against
  2101. * @param epsilon (Default: very small number)
  2102. * @returns true if they are equal
  2103. */
  2104. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2105. /**
  2106. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2107. * @param x x value to compare against
  2108. * @param y y value to compare against
  2109. * @param z z value to compare against
  2110. * @param w w value to compare against
  2111. * @returns true if equal
  2112. */
  2113. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2114. /**
  2115. * Multiplies in place the current Vector4 by the given one.
  2116. * @param otherVector vector to multiple with
  2117. * @returns the updated Vector4.
  2118. */
  2119. multiplyInPlace(otherVector: Vector4): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2122. * @param otherVector vector to multiple with
  2123. * @returns resulting new vector
  2124. */
  2125. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2128. * @param otherVector vector to multiple with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2135. * @param x x value multiply with
  2136. * @param y y value multiply with
  2137. * @param z z value multiply with
  2138. * @param w w value multiply with
  2139. * @returns resulting new vector
  2140. */
  2141. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2142. /**
  2143. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2144. * @param otherVector vector to devide with
  2145. * @returns resulting new vector
  2146. */
  2147. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2150. * @param otherVector vector to devide with
  2151. * @param result vector to store the result
  2152. * @returns the current Vector4.
  2153. */
  2154. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2155. /**
  2156. * Divides the current Vector3 coordinates by the given ones.
  2157. * @param otherVector vector to devide with
  2158. * @returns the updated Vector3.
  2159. */
  2160. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2161. /**
  2162. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2163. * @param other defines the second operand
  2164. * @returns the current updated Vector4
  2165. */
  2166. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2167. /**
  2168. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2169. * @param other defines the second operand
  2170. * @returns the current updated Vector4
  2171. */
  2172. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2173. /**
  2174. * Gets a new Vector4 from current Vector4 floored values
  2175. * @returns a new Vector4
  2176. */
  2177. floor(): Vector4;
  2178. /**
  2179. * Gets a new Vector4 from current Vector3 floored values
  2180. * @returns a new Vector4
  2181. */
  2182. fract(): Vector4;
  2183. /**
  2184. * Returns the Vector4 length (float).
  2185. * @returns the length
  2186. */
  2187. length(): number;
  2188. /**
  2189. * Returns the Vector4 squared length (float).
  2190. * @returns the length squared
  2191. */
  2192. lengthSquared(): number;
  2193. /**
  2194. * Normalizes in place the Vector4.
  2195. * @returns the updated Vector4.
  2196. */
  2197. normalize(): Vector4;
  2198. /**
  2199. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2200. * @returns this converted to a new vector3
  2201. */
  2202. toVector3(): Vector3;
  2203. /**
  2204. * Returns a new Vector4 copied from the current one.
  2205. * @returns the new cloned vector
  2206. */
  2207. clone(): Vector4;
  2208. /**
  2209. * Updates the current Vector4 with the given one coordinates.
  2210. * @param source the source vector to copy from
  2211. * @returns the updated Vector4.
  2212. */
  2213. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2214. /**
  2215. * Updates the current Vector4 coordinates with the given floats.
  2216. * @param x float to copy from
  2217. * @param y float to copy from
  2218. * @param z float to copy from
  2219. * @param w float to copy from
  2220. * @returns the updated Vector4.
  2221. */
  2222. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2223. /**
  2224. * Updates the current Vector4 coordinates with the given floats.
  2225. * @param x float to set from
  2226. * @param y float to set from
  2227. * @param z float to set from
  2228. * @param w float to set from
  2229. * @returns the updated Vector4.
  2230. */
  2231. set(x: number, y: number, z: number, w: number): Vector4;
  2232. /**
  2233. * Copies the given float to the current Vector3 coordinates
  2234. * @param v defines the x, y, z and w coordinates of the operand
  2235. * @returns the current updated Vector3
  2236. */
  2237. setAll(v: number): Vector4;
  2238. /**
  2239. * Returns a new Vector4 set from the starting index of the given array.
  2240. * @param array the array to pull values from
  2241. * @param offset the offset into the array to start at
  2242. * @returns the new vector
  2243. */
  2244. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2245. /**
  2246. * Updates the given vector "result" from the starting index of the given array.
  2247. * @param array the array to pull values from
  2248. * @param offset the offset into the array to start at
  2249. * @param result the vector to store the result in
  2250. */
  2251. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2252. /**
  2253. * Updates the given vector "result" from the starting index of the given Float32Array.
  2254. * @param array the array to pull values from
  2255. * @param offset the offset into the array to start at
  2256. * @param result the vector to store the result in
  2257. */
  2258. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2259. /**
  2260. * Updates the given vector "result" coordinates from the given floats.
  2261. * @param x float to set from
  2262. * @param y float to set from
  2263. * @param z float to set from
  2264. * @param w float to set from
  2265. * @param result the vector to the floats in
  2266. */
  2267. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2268. /**
  2269. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2270. * @returns the new vector
  2271. */
  2272. static Zero(): Vector4;
  2273. /**
  2274. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2275. * @returns the new vector
  2276. */
  2277. static One(): Vector4;
  2278. /**
  2279. * Returns a new normalized Vector4 from the given one.
  2280. * @param vector the vector to normalize
  2281. * @returns the vector
  2282. */
  2283. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2284. /**
  2285. * Updates the given vector "result" from the normalization of the given one.
  2286. * @param vector the vector to normalize
  2287. * @param result the vector to store the result in
  2288. */
  2289. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2290. /**
  2291. * Returns a vector with the minimum values from the left and right vectors
  2292. * @param left left vector to minimize
  2293. * @param right right vector to minimize
  2294. * @returns a new vector with the minimum of the left and right vector values
  2295. */
  2296. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2297. /**
  2298. * Returns a vector with the maximum values from the left and right vectors
  2299. * @param left left vector to maximize
  2300. * @param right right vector to maximize
  2301. * @returns a new vector with the maximum of the left and right vector values
  2302. */
  2303. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2304. /**
  2305. * Returns the distance (float) between the vectors "value1" and "value2".
  2306. * @param value1 value to calulate the distance between
  2307. * @param value2 value to calulate the distance between
  2308. * @return the distance between the two vectors
  2309. */
  2310. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2311. /**
  2312. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2313. * @param value1 value to calulate the distance between
  2314. * @param value2 value to calulate the distance between
  2315. * @return the distance between the two vectors squared
  2316. */
  2317. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2318. /**
  2319. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2320. * @param value1 value to calulate the center between
  2321. * @param value2 value to calulate the center between
  2322. * @return the center between the two vectors
  2323. */
  2324. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2325. /**
  2326. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2327. * This methods computes transformed normalized direction vectors only.
  2328. * @param vector the vector to transform
  2329. * @param transformation the transformation matrix to apply
  2330. * @returns the new vector
  2331. */
  2332. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2333. /**
  2334. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2335. * This methods computes transformed normalized direction vectors only.
  2336. * @param vector the vector to transform
  2337. * @param transformation the transformation matrix to apply
  2338. * @param result the vector to store the result in
  2339. */
  2340. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2341. /**
  2342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2343. * This methods computes transformed normalized direction vectors only.
  2344. * @param x value to transform
  2345. * @param y value to transform
  2346. * @param z value to transform
  2347. * @param w value to transform
  2348. * @param transformation the transformation matrix to apply
  2349. * @param result the vector to store the results in
  2350. */
  2351. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2352. /**
  2353. * Creates a new Vector4 from a Vector3
  2354. * @param source defines the source data
  2355. * @param w defines the 4th component (default is 0)
  2356. * @returns a new Vector4
  2357. */
  2358. static FromVector3(source: Vector3, w?: number): Vector4;
  2359. }
  2360. /**
  2361. * Class used to store quaternion data
  2362. * @see https://en.wikipedia.org/wiki/Quaternion
  2363. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2364. */
  2365. export class Quaternion {
  2366. /** defines the first component (0 by default) */
  2367. x: number;
  2368. /** defines the second component (0 by default) */
  2369. y: number;
  2370. /** defines the third component (0 by default) */
  2371. z: number;
  2372. /** defines the fourth component (1.0 by default) */
  2373. w: number;
  2374. /**
  2375. * Creates a new Quaternion from the given floats
  2376. * @param x defines the first component (0 by default)
  2377. * @param y defines the second component (0 by default)
  2378. * @param z defines the third component (0 by default)
  2379. * @param w defines the fourth component (1.0 by default)
  2380. */
  2381. constructor(
  2382. /** defines the first component (0 by default) */
  2383. x?: number,
  2384. /** defines the second component (0 by default) */
  2385. y?: number,
  2386. /** defines the third component (0 by default) */
  2387. z?: number,
  2388. /** defines the fourth component (1.0 by default) */
  2389. w?: number);
  2390. /**
  2391. * Gets a string representation for the current quaternion
  2392. * @returns a string with the Quaternion coordinates
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * Gets the class name of the quaternion
  2397. * @returns the string "Quaternion"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Gets a hash code for this quaternion
  2402. * @returns the quaternion hash code
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Copy the quaternion to an array
  2407. * @returns a new array populated with 4 elements from the quaternion coordinates
  2408. */
  2409. asArray(): number[];
  2410. /**
  2411. * Check if two quaternions are equals
  2412. * @param otherQuaternion defines the second operand
  2413. * @return true if the current quaternion and the given one coordinates are strictly equals
  2414. */
  2415. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2416. /**
  2417. * Clone the current quaternion
  2418. * @returns a new quaternion copied from the current one
  2419. */
  2420. clone(): Quaternion;
  2421. /**
  2422. * Copy a quaternion to the current one
  2423. * @param other defines the other quaternion
  2424. * @returns the updated current quaternion
  2425. */
  2426. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2427. /**
  2428. * Updates the current quaternion with the given float coordinates
  2429. * @param x defines the x coordinate
  2430. * @param y defines the y coordinate
  2431. * @param z defines the z coordinate
  2432. * @param w defines the w coordinate
  2433. * @returns the updated current quaternion
  2434. */
  2435. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2436. /**
  2437. * Updates the current quaternion from the given float coordinates
  2438. * @param x defines the x coordinate
  2439. * @param y defines the y coordinate
  2440. * @param z defines the z coordinate
  2441. * @param w defines the w coordinate
  2442. * @returns the updated current quaternion
  2443. */
  2444. set(x: number, y: number, z: number, w: number): Quaternion;
  2445. /**
  2446. * Adds two quaternions
  2447. * @param other defines the second operand
  2448. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2449. */
  2450. add(other: DeepImmutable<Quaternion>): Quaternion;
  2451. /**
  2452. * Add a quaternion to the current one
  2453. * @param other defines the quaternion to add
  2454. * @returns the current quaternion
  2455. */
  2456. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2457. /**
  2458. * Subtract two quaternions
  2459. * @param other defines the second operand
  2460. * @returns a new quaternion as the subtraction result of the given one from the current one
  2461. */
  2462. subtract(other: Quaternion): Quaternion;
  2463. /**
  2464. * Multiplies the current quaternion by a scale factor
  2465. * @param value defines the scale factor
  2466. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2467. */
  2468. scale(value: number): Quaternion;
  2469. /**
  2470. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2471. * @param scale defines the scale factor
  2472. * @param result defines the Quaternion object where to store the result
  2473. * @returns the unmodified current quaternion
  2474. */
  2475. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2476. /**
  2477. * Multiplies in place the current quaternion by a scale factor
  2478. * @param value defines the scale factor
  2479. * @returns the current modified quaternion
  2480. */
  2481. scaleInPlace(value: number): Quaternion;
  2482. /**
  2483. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Quaternion object where to store the result
  2486. * @returns the unmodified current quaternion
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2489. /**
  2490. * Multiplies two quaternions
  2491. * @param q1 defines the second operand
  2492. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2493. */
  2494. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2495. /**
  2496. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2497. * @param q1 defines the second operand
  2498. * @param result defines the target quaternion
  2499. * @returns the current quaternion
  2500. */
  2501. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2502. /**
  2503. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2504. * @param q1 defines the second operand
  2505. * @returns the currentupdated quaternion
  2506. */
  2507. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2508. /**
  2509. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2510. * @param ref defines the target quaternion
  2511. * @returns the current quaternion
  2512. */
  2513. conjugateToRef(ref: Quaternion): Quaternion;
  2514. /**
  2515. * Conjugates in place (1-q) the current quaternion
  2516. * @returns the current updated quaternion
  2517. */
  2518. conjugateInPlace(): Quaternion;
  2519. /**
  2520. * Conjugates in place (1-q) the current quaternion
  2521. * @returns a new quaternion
  2522. */
  2523. conjugate(): Quaternion;
  2524. /**
  2525. * Gets length of current quaternion
  2526. * @returns the quaternion length (float)
  2527. */
  2528. length(): number;
  2529. /**
  2530. * Normalize in place the current quaternion
  2531. * @returns the current updated quaternion
  2532. */
  2533. normalize(): Quaternion;
  2534. /**
  2535. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2536. * @param order is a reserved parameter and is ignore for now
  2537. * @returns a new Vector3 containing the Euler angles
  2538. */
  2539. toEulerAngles(order?: string): Vector3;
  2540. /**
  2541. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2542. * @param result defines the vector which will be filled with the Euler angles
  2543. * @param order is a reserved parameter and is ignore for now
  2544. * @returns the current unchanged quaternion
  2545. */
  2546. toEulerAnglesToRef(result: Vector3): Quaternion;
  2547. /**
  2548. * Updates the given rotation matrix with the current quaternion values
  2549. * @param result defines the target matrix
  2550. * @returns the current unchanged quaternion
  2551. */
  2552. toRotationMatrix(result: Matrix): Quaternion;
  2553. /**
  2554. * Updates the current quaternion from the given rotation matrix values
  2555. * @param matrix defines the source matrix
  2556. * @returns the current updated quaternion
  2557. */
  2558. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2559. /**
  2560. * Creates a new quaternion from a rotation matrix
  2561. * @param matrix defines the source matrix
  2562. * @returns a new quaternion created from the given rotation matrix values
  2563. */
  2564. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2565. /**
  2566. * Updates the given quaternion with the given rotation matrix values
  2567. * @param matrix defines the source matrix
  2568. * @param result defines the target quaternion
  2569. */
  2570. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2571. /**
  2572. * Returns the dot product (float) between the quaternions "left" and "right"
  2573. * @param left defines the left operand
  2574. * @param right defines the right operand
  2575. * @returns the dot product
  2576. */
  2577. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2578. /**
  2579. * Checks if the two quaternions are close to each other
  2580. * @param quat0 defines the first quaternion to check
  2581. * @param quat1 defines the second quaternion to check
  2582. * @returns true if the two quaternions are close to each other
  2583. */
  2584. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2585. /**
  2586. * Creates an empty quaternion
  2587. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2588. */
  2589. static Zero(): Quaternion;
  2590. /**
  2591. * Inverse a given quaternion
  2592. * @param q defines the source quaternion
  2593. * @returns a new quaternion as the inverted current quaternion
  2594. */
  2595. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Inverse a given quaternion
  2598. * @param q defines the source quaternion
  2599. * @param result the quaternion the result will be stored in
  2600. * @returns the result quaternion
  2601. */
  2602. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2603. /**
  2604. * Creates an identity quaternion
  2605. * @returns the identity quaternion
  2606. */
  2607. static Identity(): Quaternion;
  2608. /**
  2609. * Gets a boolean indicating if the given quaternion is identity
  2610. * @param quaternion defines the quaternion to check
  2611. * @returns true if the quaternion is identity
  2612. */
  2613. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2614. /**
  2615. * Creates a quaternion from a rotation around an axis
  2616. * @param axis defines the axis to use
  2617. * @param angle defines the angle to use
  2618. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2619. */
  2620. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2621. /**
  2622. * Creates a rotation around an axis and stores it into the given quaternion
  2623. * @param axis defines the axis to use
  2624. * @param angle defines the angle to use
  2625. * @param result defines the target quaternion
  2626. * @returns the target quaternion
  2627. */
  2628. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2629. /**
  2630. * Creates a new quaternion from data stored into an array
  2631. * @param array defines the data source
  2632. * @param offset defines the offset in the source array where the data starts
  2633. * @returns a new quaternion
  2634. */
  2635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2636. /**
  2637. * Create a quaternion from Euler rotation angles
  2638. * @param x Pitch
  2639. * @param y Yaw
  2640. * @param z Roll
  2641. * @returns the new Quaternion
  2642. */
  2643. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2644. /**
  2645. * Updates a quaternion from Euler rotation angles
  2646. * @param x Pitch
  2647. * @param y Yaw
  2648. * @param z Roll
  2649. * @param result the quaternion to store the result
  2650. * @returns the updated quaternion
  2651. */
  2652. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2653. /**
  2654. * Create a quaternion from Euler rotation vector
  2655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2656. * @returns the new Quaternion
  2657. */
  2658. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2659. /**
  2660. * Updates a quaternion from Euler rotation vector
  2661. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2662. * @param result the quaternion to store the result
  2663. * @returns the updated quaternion
  2664. */
  2665. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2666. /**
  2667. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2668. * @param yaw defines the rotation around Y axis
  2669. * @param pitch defines the rotation around X axis
  2670. * @param roll defines the rotation around Z axis
  2671. * @returns the new quaternion
  2672. */
  2673. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2674. /**
  2675. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2676. * @param yaw defines the rotation around Y axis
  2677. * @param pitch defines the rotation around X axis
  2678. * @param roll defines the rotation around Z axis
  2679. * @param result defines the target quaternion
  2680. */
  2681. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2682. /**
  2683. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2684. * @param alpha defines the rotation around first axis
  2685. * @param beta defines the rotation around second axis
  2686. * @param gamma defines the rotation around third axis
  2687. * @returns the new quaternion
  2688. */
  2689. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2690. /**
  2691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2692. * @param alpha defines the rotation around first axis
  2693. * @param beta defines the rotation around second axis
  2694. * @param gamma defines the rotation around third axis
  2695. * @param result defines the target quaternion
  2696. */
  2697. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2698. /**
  2699. * 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)
  2700. * @param axis1 defines the first axis
  2701. * @param axis2 defines the second axis
  2702. * @param axis3 defines the third axis
  2703. * @returns the new quaternion
  2704. */
  2705. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2706. /**
  2707. * 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
  2708. * @param axis1 defines the first axis
  2709. * @param axis2 defines the second axis
  2710. * @param axis3 defines the third axis
  2711. * @param ref defines the target quaternion
  2712. */
  2713. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2714. /**
  2715. * Interpolates between two quaternions
  2716. * @param left defines first quaternion
  2717. * @param right defines second quaternion
  2718. * @param amount defines the gradient to use
  2719. * @returns the new interpolated quaternion
  2720. */
  2721. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2722. /**
  2723. * Interpolates between two quaternions and stores it into a target quaternion
  2724. * @param left defines first quaternion
  2725. * @param right defines second quaternion
  2726. * @param amount defines the gradient to use
  2727. * @param result defines the target quaternion
  2728. */
  2729. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2730. /**
  2731. * Interpolate between two quaternions using Hermite interpolation
  2732. * @param value1 defines first quaternion
  2733. * @param tangent1 defines the incoming tangent
  2734. * @param value2 defines second quaternion
  2735. * @param tangent2 defines the outgoing tangent
  2736. * @param amount defines the target quaternion
  2737. * @returns the new interpolated quaternion
  2738. */
  2739. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2740. }
  2741. /**
  2742. * Class used to store matrix data (4x4)
  2743. */
  2744. export class Matrix {
  2745. private static _updateFlagSeed;
  2746. private static _identityReadOnly;
  2747. private _isIdentity;
  2748. private _isIdentityDirty;
  2749. private _isIdentity3x2;
  2750. private _isIdentity3x2Dirty;
  2751. /**
  2752. * Gets the update flag of the matrix which is an unique number for the matrix.
  2753. * It will be incremented every time the matrix data change.
  2754. * You can use it to speed the comparison between two versions of the same matrix.
  2755. */
  2756. updateFlag: number;
  2757. private readonly _m;
  2758. /**
  2759. * Gets the internal data of the matrix
  2760. */
  2761. readonly m: DeepImmutable<Float32Array>;
  2762. /** @hidden */
  2763. _markAsUpdated(): void;
  2764. /** @hidden */
  2765. private _updateIdentityStatus;
  2766. /**
  2767. * Creates an empty matrix (filled with zeros)
  2768. */
  2769. constructor();
  2770. /**
  2771. * Check if the current matrix is identity
  2772. * @returns true is the matrix is the identity matrix
  2773. */
  2774. isIdentity(): boolean;
  2775. /**
  2776. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2777. * @returns true is the matrix is the identity matrix
  2778. */
  2779. isIdentityAs3x2(): boolean;
  2780. /**
  2781. * Gets the determinant of the matrix
  2782. * @returns the matrix determinant
  2783. */
  2784. determinant(): number;
  2785. /**
  2786. * Returns the matrix as a Float32Array
  2787. * @returns the matrix underlying array
  2788. */
  2789. toArray(): DeepImmutable<Float32Array>;
  2790. /**
  2791. * Returns the matrix as a Float32Array
  2792. * @returns the matrix underlying array.
  2793. */
  2794. asArray(): DeepImmutable<Float32Array>;
  2795. /**
  2796. * Inverts the current matrix in place
  2797. * @returns the current inverted matrix
  2798. */
  2799. invert(): Matrix;
  2800. /**
  2801. * Sets all the matrix elements to zero
  2802. * @returns the current matrix
  2803. */
  2804. reset(): Matrix;
  2805. /**
  2806. * Adds the current matrix with a second one
  2807. * @param other defines the matrix to add
  2808. * @returns a new matrix as the addition of the current matrix and the given one
  2809. */
  2810. add(other: DeepImmutable<Matrix>): Matrix;
  2811. /**
  2812. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2813. * @param other defines the matrix to add
  2814. * @param result defines the target matrix
  2815. * @returns the current matrix
  2816. */
  2817. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2818. /**
  2819. * Adds in place the given matrix to the current matrix
  2820. * @param other defines the second operand
  2821. * @returns the current updated matrix
  2822. */
  2823. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2824. /**
  2825. * Sets the given matrix to the current inverted Matrix
  2826. * @param other defines the target matrix
  2827. * @returns the unmodified current matrix
  2828. */
  2829. invertToRef(other: Matrix): Matrix;
  2830. /**
  2831. * add a value at the specified position in the current Matrix
  2832. * @param index the index of the value within the matrix. between 0 and 15.
  2833. * @param value the value to be added
  2834. * @returns the current updated matrix
  2835. */
  2836. addAtIndex(index: number, value: number): Matrix;
  2837. /**
  2838. * mutiply the specified position in the current Matrix by a value
  2839. * @param index the index of the value within the matrix. between 0 and 15.
  2840. * @param value the value to be added
  2841. * @returns the current updated matrix
  2842. */
  2843. multiplyAtIndex(index: number, value: number): Matrix;
  2844. /**
  2845. * Inserts the translation vector (using 3 floats) in the current matrix
  2846. * @param x defines the 1st component of the translation
  2847. * @param y defines the 2nd component of the translation
  2848. * @param z defines the 3rd component of the translation
  2849. * @returns the current updated matrix
  2850. */
  2851. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2852. /**
  2853. * Adds the translation vector (using 3 floats) in the current matrix
  2854. * @param x defines the 1st component of the translation
  2855. * @param y defines the 2nd component of the translation
  2856. * @param z defines the 3rd component of the translation
  2857. * @returns the current updated matrix
  2858. */
  2859. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2860. /**
  2861. * Inserts the translation vector in the current matrix
  2862. * @param vector3 defines the translation to insert
  2863. * @returns the current updated matrix
  2864. */
  2865. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2866. /**
  2867. * Gets the translation value of the current matrix
  2868. * @returns a new Vector3 as the extracted translation from the matrix
  2869. */
  2870. getTranslation(): Vector3;
  2871. /**
  2872. * Fill a Vector3 with the extracted translation from the matrix
  2873. * @param result defines the Vector3 where to store the translation
  2874. * @returns the current matrix
  2875. */
  2876. getTranslationToRef(result: Vector3): Matrix;
  2877. /**
  2878. * Remove rotation and scaling part from the matrix
  2879. * @returns the updated matrix
  2880. */
  2881. removeRotationAndScaling(): Matrix;
  2882. /**
  2883. * Multiply two matrices
  2884. * @param other defines the second operand
  2885. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2886. */
  2887. multiply(other: DeepImmutable<Matrix>): Matrix;
  2888. /**
  2889. * Copy the current matrix from the given one
  2890. * @param other defines the source matrix
  2891. * @returns the current updated matrix
  2892. */
  2893. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2894. /**
  2895. * Populates the given array from the starting index with the current matrix values
  2896. * @param array defines the target array
  2897. * @param offset defines the offset in the target array where to start storing values
  2898. * @returns the current matrix
  2899. */
  2900. copyToArray(array: Float32Array, offset?: number): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2903. * @param other defines the second operand
  2904. * @param result defines the matrix where to store the multiplication
  2905. * @returns the current matrix
  2906. */
  2907. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2910. * @param other defines the second operand
  2911. * @param result defines the array where to store the multiplication
  2912. * @param offset defines the offset in the target array where to start storing values
  2913. * @returns the current matrix
  2914. */
  2915. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2916. /**
  2917. * Check equality between this matrix and a second one
  2918. * @param value defines the second matrix to compare
  2919. * @returns true is the current matrix and the given one values are strictly equal
  2920. */
  2921. equals(value: DeepImmutable<Matrix>): boolean;
  2922. /**
  2923. * Clone the current matrix
  2924. * @returns a new matrix from the current matrix
  2925. */
  2926. clone(): Matrix;
  2927. /**
  2928. * Returns the name of the current matrix class
  2929. * @returns the string "Matrix"
  2930. */
  2931. getClassName(): string;
  2932. /**
  2933. * Gets the hash code of the current matrix
  2934. * @returns the hash code
  2935. */
  2936. getHashCode(): number;
  2937. /**
  2938. * Decomposes the current Matrix into a translation, rotation and scaling components
  2939. * @param scale defines the scale vector3 given as a reference to update
  2940. * @param rotation defines the rotation quaternion given as a reference to update
  2941. * @param translation defines the translation vector3 given as a reference to update
  2942. * @returns true if operation was successful
  2943. */
  2944. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2945. /**
  2946. * Gets specific row of the matrix
  2947. * @param index defines the number of the row to get
  2948. * @returns the index-th row of the current matrix as a new Vector4
  2949. */
  2950. getRow(index: number): Nullable<Vector4>;
  2951. /**
  2952. * Sets the index-th row of the current matrix to the vector4 values
  2953. * @param index defines the number of the row to set
  2954. * @param row defines the target vector4
  2955. * @returns the updated current matrix
  2956. */
  2957. setRow(index: number, row: Vector4): Matrix;
  2958. /**
  2959. * Compute the transpose of the matrix
  2960. * @returns the new transposed matrix
  2961. */
  2962. transpose(): Matrix;
  2963. /**
  2964. * Compute the transpose of the matrix and store it in a given matrix
  2965. * @param result defines the target matrix
  2966. * @returns the current matrix
  2967. */
  2968. transposeToRef(result: Matrix): Matrix;
  2969. /**
  2970. * Sets the index-th row of the current matrix with the given 4 x float values
  2971. * @param index defines the row index
  2972. * @param x defines the x component to set
  2973. * @param y defines the y component to set
  2974. * @param z defines the z component to set
  2975. * @param w defines the w component to set
  2976. * @returns the updated current matrix
  2977. */
  2978. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2979. /**
  2980. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2981. * @param scale defines the scale factor
  2982. * @returns a new matrix
  2983. */
  2984. scale(scale: number): Matrix;
  2985. /**
  2986. * Scale the current matrix values by a factor to a given result matrix
  2987. * @param scale defines the scale factor
  2988. * @param result defines the matrix to store the result
  2989. * @returns the current matrix
  2990. */
  2991. scaleToRef(scale: number, result: Matrix): Matrix;
  2992. /**
  2993. * Scale the current matrix values by a factor and add the result to a given matrix
  2994. * @param scale defines the scale factor
  2995. * @param result defines the Matrix to store the result
  2996. * @returns the current matrix
  2997. */
  2998. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  2999. /**
  3000. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3001. * @param ref matrix to store the result
  3002. */
  3003. toNormalMatrix(ref: Matrix): void;
  3004. /**
  3005. * Gets only rotation part of the current matrix
  3006. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3007. */
  3008. getRotationMatrix(): Matrix;
  3009. /**
  3010. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3011. * @param result defines the target matrix to store data to
  3012. * @returns the current matrix
  3013. */
  3014. getRotationMatrixToRef(result: Matrix): Matrix;
  3015. /**
  3016. * Toggles model matrix from being right handed to left handed in place and vice versa
  3017. */
  3018. toggleModelMatrixHandInPlace(): void;
  3019. /**
  3020. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3021. */
  3022. toggleProjectionMatrixHandInPlace(): void;
  3023. /**
  3024. * Creates a matrix from an array
  3025. * @param array defines the source array
  3026. * @param offset defines an offset in the source array
  3027. * @returns a new Matrix set from the starting index of the given array
  3028. */
  3029. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3030. /**
  3031. * Copy the content of an array into a given matrix
  3032. * @param array defines the source array
  3033. * @param offset defines an offset in the source array
  3034. * @param result defines the target matrix
  3035. */
  3036. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3037. /**
  3038. * Stores an array into a matrix after having multiplied each component by a given factor
  3039. * @param array defines the source array
  3040. * @param offset defines the offset in the source array
  3041. * @param scale defines the scaling factor
  3042. * @param result defines the target matrix
  3043. */
  3044. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3045. /**
  3046. * Gets an identity matrix that must not be updated
  3047. */
  3048. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3049. /**
  3050. * Stores a list of values (16) inside a given matrix
  3051. * @param initialM11 defines 1st value of 1st row
  3052. * @param initialM12 defines 2nd value of 1st row
  3053. * @param initialM13 defines 3rd value of 1st row
  3054. * @param initialM14 defines 4th value of 1st row
  3055. * @param initialM21 defines 1st value of 2nd row
  3056. * @param initialM22 defines 2nd value of 2nd row
  3057. * @param initialM23 defines 3rd value of 2nd row
  3058. * @param initialM24 defines 4th value of 2nd row
  3059. * @param initialM31 defines 1st value of 3rd row
  3060. * @param initialM32 defines 2nd value of 3rd row
  3061. * @param initialM33 defines 3rd value of 3rd row
  3062. * @param initialM34 defines 4th value of 3rd row
  3063. * @param initialM41 defines 1st value of 4th row
  3064. * @param initialM42 defines 2nd value of 4th row
  3065. * @param initialM43 defines 3rd value of 4th row
  3066. * @param initialM44 defines 4th value of 4th row
  3067. * @param result defines the target matrix
  3068. */
  3069. 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;
  3070. /**
  3071. * Creates new matrix from a list of values (16)
  3072. * @param initialM11 defines 1st value of 1st row
  3073. * @param initialM12 defines 2nd value of 1st row
  3074. * @param initialM13 defines 3rd value of 1st row
  3075. * @param initialM14 defines 4th value of 1st row
  3076. * @param initialM21 defines 1st value of 2nd row
  3077. * @param initialM22 defines 2nd value of 2nd row
  3078. * @param initialM23 defines 3rd value of 2nd row
  3079. * @param initialM24 defines 4th value of 2nd row
  3080. * @param initialM31 defines 1st value of 3rd row
  3081. * @param initialM32 defines 2nd value of 3rd row
  3082. * @param initialM33 defines 3rd value of 3rd row
  3083. * @param initialM34 defines 4th value of 3rd row
  3084. * @param initialM41 defines 1st value of 4th row
  3085. * @param initialM42 defines 2nd value of 4th row
  3086. * @param initialM43 defines 3rd value of 4th row
  3087. * @param initialM44 defines 4th value of 4th row
  3088. * @returns the new matrix
  3089. */
  3090. 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;
  3091. /**
  3092. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3093. * @param scale defines the scale vector3
  3094. * @param rotation defines the rotation quaternion
  3095. * @param translation defines the translation vector3
  3096. * @returns a new matrix
  3097. */
  3098. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3099. /**
  3100. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3101. * @param scale defines the scale vector3
  3102. * @param rotation defines the rotation quaternion
  3103. * @param translation defines the translation vector3
  3104. * @param result defines the target matrix
  3105. */
  3106. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3107. /**
  3108. * Creates a new identity matrix
  3109. * @returns a new identity matrix
  3110. */
  3111. static Identity(): Matrix;
  3112. /**
  3113. * Creates a new identity matrix and stores the result in a given matrix
  3114. * @param result defines the target matrix
  3115. */
  3116. static IdentityToRef(result: Matrix): void;
  3117. /**
  3118. * Creates a new zero matrix
  3119. * @returns a new zero matrix
  3120. */
  3121. static Zero(): Matrix;
  3122. /**
  3123. * Creates a new rotation matrix for "angle" radians around the X axis
  3124. * @param angle defines the angle (in radians) to use
  3125. * @return the new matrix
  3126. */
  3127. static RotationX(angle: number): Matrix;
  3128. /**
  3129. * Creates a new matrix as the invert of a given matrix
  3130. * @param source defines the source matrix
  3131. * @returns the new matrix
  3132. */
  3133. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3134. /**
  3135. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3136. * @param angle defines the angle (in radians) to use
  3137. * @param result defines the target matrix
  3138. */
  3139. static RotationXToRef(angle: number, result: Matrix): void;
  3140. /**
  3141. * Creates a new rotation matrix for "angle" radians around the Y axis
  3142. * @param angle defines the angle (in radians) to use
  3143. * @return the new matrix
  3144. */
  3145. static RotationY(angle: number): Matrix;
  3146. /**
  3147. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3148. * @param angle defines the angle (in radians) to use
  3149. * @param result defines the target matrix
  3150. */
  3151. static RotationYToRef(angle: number, result: Matrix): void;
  3152. /**
  3153. * Creates a new rotation matrix for "angle" radians around the Z axis
  3154. * @param angle defines the angle (in radians) to use
  3155. * @return the new matrix
  3156. */
  3157. static RotationZ(angle: number): Matrix;
  3158. /**
  3159. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3160. * @param angle defines the angle (in radians) to use
  3161. * @param result defines the target matrix
  3162. */
  3163. static RotationZToRef(angle: number, result: Matrix): void;
  3164. /**
  3165. * Creates a new rotation matrix for "angle" radians around the given axis
  3166. * @param axis defines the axis to use
  3167. * @param angle defines the angle (in radians) to use
  3168. * @return the new matrix
  3169. */
  3170. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3171. /**
  3172. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3173. * @param axis defines the axis to use
  3174. * @param angle defines the angle (in radians) to use
  3175. * @param result defines the target matrix
  3176. */
  3177. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3178. /**
  3179. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3180. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3181. * @param from defines the vector to align
  3182. * @param to defines the vector to align to
  3183. * @param result defines the target matrix
  3184. */
  3185. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3186. /**
  3187. * Creates a rotation matrix
  3188. * @param yaw defines the yaw angle in radians (Y axis)
  3189. * @param pitch defines the pitch angle in radians (X axis)
  3190. * @param roll defines the roll angle in radians (X axis)
  3191. * @returns the new rotation matrix
  3192. */
  3193. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3194. /**
  3195. * Creates a rotation matrix and stores it in a given matrix
  3196. * @param yaw defines the yaw angle in radians (Y axis)
  3197. * @param pitch defines the pitch angle in radians (X axis)
  3198. * @param roll defines the roll angle in radians (X axis)
  3199. * @param result defines the target matrix
  3200. */
  3201. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3202. /**
  3203. * Creates a scaling matrix
  3204. * @param x defines the scale factor on X axis
  3205. * @param y defines the scale factor on Y axis
  3206. * @param z defines the scale factor on Z axis
  3207. * @returns the new matrix
  3208. */
  3209. static Scaling(x: number, y: number, z: number): Matrix;
  3210. /**
  3211. * Creates a scaling matrix and stores it in a given matrix
  3212. * @param x defines the scale factor on X axis
  3213. * @param y defines the scale factor on Y axis
  3214. * @param z defines the scale factor on Z axis
  3215. * @param result defines the target matrix
  3216. */
  3217. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3218. /**
  3219. * Creates a translation matrix
  3220. * @param x defines the translation on X axis
  3221. * @param y defines the translation on Y axis
  3222. * @param z defines the translationon Z axis
  3223. * @returns the new matrix
  3224. */
  3225. static Translation(x: number, y: number, z: number): Matrix;
  3226. /**
  3227. * Creates a translation matrix and stores it in a given matrix
  3228. * @param x defines the translation on X axis
  3229. * @param y defines the translation on Y axis
  3230. * @param z defines the translationon Z axis
  3231. * @param result defines the target matrix
  3232. */
  3233. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3234. /**
  3235. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3236. * @param startValue defines the start value
  3237. * @param endValue defines the end value
  3238. * @param gradient defines the gradient factor
  3239. * @returns the new matrix
  3240. */
  3241. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3242. /**
  3243. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3244. * @param startValue defines the start value
  3245. * @param endValue defines the end value
  3246. * @param gradient defines the gradient factor
  3247. * @param result defines the Matrix object where to store data
  3248. */
  3249. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3250. /**
  3251. * Builds a new matrix whose values are computed by:
  3252. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3253. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3254. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3255. * @param startValue defines the first matrix
  3256. * @param endValue defines the second matrix
  3257. * @param gradient defines the gradient between the two matrices
  3258. * @returns the new matrix
  3259. */
  3260. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3261. /**
  3262. * Update a matrix to values which are computed by:
  3263. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3264. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3265. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3266. * @param startValue defines the first matrix
  3267. * @param endValue defines the second matrix
  3268. * @param gradient defines the gradient between the two matrices
  3269. * @param result defines the target matrix
  3270. */
  3271. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3272. /**
  3273. * 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"
  3274. * This function works in left handed mode
  3275. * @param eye defines the final position of the entity
  3276. * @param target defines where the entity should look at
  3277. * @param up defines the up vector for the entity
  3278. * @returns the new matrix
  3279. */
  3280. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3281. /**
  3282. * 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".
  3283. * This function works in left handed mode
  3284. * @param eye defines the final position of the entity
  3285. * @param target defines where the entity should look at
  3286. * @param up defines the up vector for the entity
  3287. * @param result defines the target matrix
  3288. */
  3289. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3290. /**
  3291. * 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"
  3292. * This function works in right handed mode
  3293. * @param eye defines the final position of the entity
  3294. * @param target defines where the entity should look at
  3295. * @param up defines the up vector for the entity
  3296. * @returns the new matrix
  3297. */
  3298. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3299. /**
  3300. * 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".
  3301. * This function works in right handed mode
  3302. * @param eye defines the final position of the entity
  3303. * @param target defines where the entity should look at
  3304. * @param up defines the up vector for the entity
  3305. * @param result defines the target matrix
  3306. */
  3307. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3308. /**
  3309. * Create a left-handed orthographic projection matrix
  3310. * @param width defines the viewport width
  3311. * @param height defines the viewport height
  3312. * @param znear defines the near clip plane
  3313. * @param zfar defines the far clip plane
  3314. * @returns a new matrix as a left-handed orthographic projection matrix
  3315. */
  3316. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3317. /**
  3318. * Store a left-handed orthographic projection to a given matrix
  3319. * @param width defines the viewport width
  3320. * @param height defines the viewport height
  3321. * @param znear defines the near clip plane
  3322. * @param zfar defines the far clip plane
  3323. * @param result defines the target matrix
  3324. */
  3325. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3326. /**
  3327. * Create a left-handed orthographic projection matrix
  3328. * @param left defines the viewport left coordinate
  3329. * @param right defines the viewport right coordinate
  3330. * @param bottom defines the viewport bottom coordinate
  3331. * @param top defines the viewport top coordinate
  3332. * @param znear defines the near clip plane
  3333. * @param zfar defines the far clip plane
  3334. * @returns a new matrix as a left-handed orthographic projection matrix
  3335. */
  3336. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3337. /**
  3338. * Stores a left-handed orthographic projection into a given matrix
  3339. * @param left defines the viewport left coordinate
  3340. * @param right defines the viewport right coordinate
  3341. * @param bottom defines the viewport bottom coordinate
  3342. * @param top defines the viewport top coordinate
  3343. * @param znear defines the near clip plane
  3344. * @param zfar defines the far clip plane
  3345. * @param result defines the target matrix
  3346. */
  3347. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3348. /**
  3349. * Creates a right-handed orthographic projection matrix
  3350. * @param left defines the viewport left coordinate
  3351. * @param right defines the viewport right coordinate
  3352. * @param bottom defines the viewport bottom coordinate
  3353. * @param top defines the viewport top coordinate
  3354. * @param znear defines the near clip plane
  3355. * @param zfar defines the far clip plane
  3356. * @returns a new matrix as a right-handed orthographic projection matrix
  3357. */
  3358. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3359. /**
  3360. * Stores a right-handed orthographic projection into a given matrix
  3361. * @param left defines the viewport left coordinate
  3362. * @param right defines the viewport right coordinate
  3363. * @param bottom defines the viewport bottom coordinate
  3364. * @param top defines the viewport top coordinate
  3365. * @param znear defines the near clip plane
  3366. * @param zfar defines the far clip plane
  3367. * @param result defines the target matrix
  3368. */
  3369. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3370. /**
  3371. * Creates a left-handed perspective projection matrix
  3372. * @param width defines the viewport width
  3373. * @param height defines the viewport height
  3374. * @param znear defines the near clip plane
  3375. * @param zfar defines the far clip plane
  3376. * @returns a new matrix as a left-handed perspective projection matrix
  3377. */
  3378. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3379. /**
  3380. * Creates a left-handed perspective projection matrix
  3381. * @param fov defines the horizontal field of view
  3382. * @param aspect defines the aspect ratio
  3383. * @param znear defines the near clip plane
  3384. * @param zfar defines the far clip plane
  3385. * @returns a new matrix as a left-handed perspective projection matrix
  3386. */
  3387. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3388. /**
  3389. * Stores a left-handed perspective projection into a given matrix
  3390. * @param fov defines the horizontal field of view
  3391. * @param aspect defines the aspect ratio
  3392. * @param znear defines the near clip plane
  3393. * @param zfar defines the far clip plane
  3394. * @param result defines the target matrix
  3395. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3396. */
  3397. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3398. /**
  3399. * Creates a right-handed perspective projection matrix
  3400. * @param fov defines the horizontal field of view
  3401. * @param aspect defines the aspect ratio
  3402. * @param znear defines the near clip plane
  3403. * @param zfar defines the far clip plane
  3404. * @returns a new matrix as a right-handed perspective projection matrix
  3405. */
  3406. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3407. /**
  3408. * Stores a right-handed perspective projection into a given matrix
  3409. * @param fov defines the horizontal field of view
  3410. * @param aspect defines the aspect ratio
  3411. * @param znear defines the near clip plane
  3412. * @param zfar defines the far clip plane
  3413. * @param result defines the target matrix
  3414. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3415. */
  3416. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3417. /**
  3418. * Stores a perspective projection for WebVR info a given matrix
  3419. * @param fov defines the field of view
  3420. * @param znear defines the near clip plane
  3421. * @param zfar defines the far clip plane
  3422. * @param result defines the target matrix
  3423. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3424. */
  3425. static PerspectiveFovWebVRToRef(fov: {
  3426. upDegrees: number;
  3427. downDegrees: number;
  3428. leftDegrees: number;
  3429. rightDegrees: number;
  3430. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3431. /**
  3432. * Computes a complete transformation matrix
  3433. * @param viewport defines the viewport to use
  3434. * @param world defines the world matrix
  3435. * @param view defines the view matrix
  3436. * @param projection defines the projection matrix
  3437. * @param zmin defines the near clip plane
  3438. * @param zmax defines the far clip plane
  3439. * @returns the transformation matrix
  3440. */
  3441. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3442. /**
  3443. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3444. * @param matrix defines the matrix to use
  3445. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3446. */
  3447. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3448. /**
  3449. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3450. * @param matrix defines the matrix to use
  3451. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3452. */
  3453. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3454. /**
  3455. * Compute the transpose of a given matrix
  3456. * @param matrix defines the matrix to transpose
  3457. * @returns the new matrix
  3458. */
  3459. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3460. /**
  3461. * Compute the transpose of a matrix and store it in a target matrix
  3462. * @param matrix defines the matrix to transpose
  3463. * @param result defines the target matrix
  3464. */
  3465. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3466. /**
  3467. * Computes a reflection matrix from a plane
  3468. * @param plane defines the reflection plane
  3469. * @returns a new matrix
  3470. */
  3471. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3472. /**
  3473. * Computes a reflection matrix from a plane
  3474. * @param plane defines the reflection plane
  3475. * @param result defines the target matrix
  3476. */
  3477. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3478. /**
  3479. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3480. * @param xaxis defines the value of the 1st axis
  3481. * @param yaxis defines the value of the 2nd axis
  3482. * @param zaxis defines the value of the 3rd axis
  3483. * @param result defines the target matrix
  3484. */
  3485. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3486. /**
  3487. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3488. * @param quat defines the quaternion to use
  3489. * @param result defines the target matrix
  3490. */
  3491. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3492. }
  3493. /**
  3494. * @hidden
  3495. */
  3496. export class TmpVectors {
  3497. static Vector2: Vector2[];
  3498. static Vector3: Vector3[];
  3499. static Vector4: Vector4[];
  3500. static Quaternion: Quaternion[];
  3501. static Matrix: Matrix[];
  3502. }
  3503. }
  3504. declare module BABYLON {
  3505. /**
  3506. * Class used to hold a RBG color
  3507. */
  3508. export class Color3 {
  3509. /**
  3510. * Defines the red component (between 0 and 1, default is 0)
  3511. */
  3512. r: number;
  3513. /**
  3514. * Defines the green component (between 0 and 1, default is 0)
  3515. */
  3516. g: number;
  3517. /**
  3518. * Defines the blue component (between 0 and 1, default is 0)
  3519. */
  3520. b: number;
  3521. /**
  3522. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3523. * @param r defines the red component (between 0 and 1, default is 0)
  3524. * @param g defines the green component (between 0 and 1, default is 0)
  3525. * @param b defines the blue component (between 0 and 1, default is 0)
  3526. */
  3527. constructor(
  3528. /**
  3529. * Defines the red component (between 0 and 1, default is 0)
  3530. */
  3531. r?: number,
  3532. /**
  3533. * Defines the green component (between 0 and 1, default is 0)
  3534. */
  3535. g?: number,
  3536. /**
  3537. * Defines the blue component (between 0 and 1, default is 0)
  3538. */
  3539. b?: number);
  3540. /**
  3541. * Creates a string with the Color3 current values
  3542. * @returns the string representation of the Color3 object
  3543. */
  3544. toString(): string;
  3545. /**
  3546. * Returns the string "Color3"
  3547. * @returns "Color3"
  3548. */
  3549. getClassName(): string;
  3550. /**
  3551. * Compute the Color3 hash code
  3552. * @returns an unique number that can be used to hash Color3 objects
  3553. */
  3554. getHashCode(): number;
  3555. /**
  3556. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3557. * @param array defines the array where to store the r,g,b components
  3558. * @param index defines an optional index in the target array to define where to start storing values
  3559. * @returns the current Color3 object
  3560. */
  3561. toArray(array: FloatArray, index?: number): Color3;
  3562. /**
  3563. * Returns a new Color4 object from the current Color3 and the given alpha
  3564. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3565. * @returns a new Color4 object
  3566. */
  3567. toColor4(alpha?: number): Color4;
  3568. /**
  3569. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3570. * @returns the new array
  3571. */
  3572. asArray(): number[];
  3573. /**
  3574. * Returns the luminance value
  3575. * @returns a float value
  3576. */
  3577. toLuminance(): number;
  3578. /**
  3579. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3580. * @param otherColor defines the second operand
  3581. * @returns the new Color3 object
  3582. */
  3583. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3584. /**
  3585. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3586. * @param otherColor defines the second operand
  3587. * @param result defines the Color3 object where to store the result
  3588. * @returns the current Color3
  3589. */
  3590. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3591. /**
  3592. * Determines equality between Color3 objects
  3593. * @param otherColor defines the second operand
  3594. * @returns true if the rgb values are equal to the given ones
  3595. */
  3596. equals(otherColor: DeepImmutable<Color3>): boolean;
  3597. /**
  3598. * Determines equality between the current Color3 object and a set of r,b,g values
  3599. * @param r defines the red component to check
  3600. * @param g defines the green component to check
  3601. * @param b defines the blue component to check
  3602. * @returns true if the rgb values are equal to the given ones
  3603. */
  3604. equalsFloats(r: number, g: number, b: number): boolean;
  3605. /**
  3606. * Multiplies in place each rgb value by scale
  3607. * @param scale defines the scaling factor
  3608. * @returns the updated Color3
  3609. */
  3610. scale(scale: number): Color3;
  3611. /**
  3612. * Multiplies the rgb values by scale and stores the result into "result"
  3613. * @param scale defines the scaling factor
  3614. * @param result defines the Color3 object where to store the result
  3615. * @returns the unmodified current Color3
  3616. */
  3617. scaleToRef(scale: number, result: Color3): Color3;
  3618. /**
  3619. * Scale the current Color3 values by a factor and add the result to a given Color3
  3620. * @param scale defines the scale factor
  3621. * @param result defines color to store the result into
  3622. * @returns the unmodified current Color3
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3625. /**
  3626. * Clamps the rgb values by the min and max values and stores the result into "result"
  3627. * @param min defines minimum clamping value (default is 0)
  3628. * @param max defines maximum clamping value (default is 1)
  3629. * @param result defines color to store the result into
  3630. * @returns the original Color3
  3631. */
  3632. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3633. /**
  3634. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3635. * @param otherColor defines the second operand
  3636. * @returns the new Color3
  3637. */
  3638. add(otherColor: DeepImmutable<Color3>): Color3;
  3639. /**
  3640. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3641. * @param otherColor defines the second operand
  3642. * @param result defines Color3 object to store the result into
  3643. * @returns the unmodified current Color3
  3644. */
  3645. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3646. /**
  3647. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3648. * @param otherColor defines the second operand
  3649. * @returns the new Color3
  3650. */
  3651. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3652. /**
  3653. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3654. * @param otherColor defines the second operand
  3655. * @param result defines Color3 object to store the result into
  3656. * @returns the unmodified current Color3
  3657. */
  3658. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3659. /**
  3660. * Copy the current object
  3661. * @returns a new Color3 copied the current one
  3662. */
  3663. clone(): Color3;
  3664. /**
  3665. * Copies the rgb values from the source in the current Color3
  3666. * @param source defines the source Color3 object
  3667. * @returns the updated Color3 object
  3668. */
  3669. copyFrom(source: DeepImmutable<Color3>): Color3;
  3670. /**
  3671. * Updates the Color3 rgb values from the given floats
  3672. * @param r defines the red component to read from
  3673. * @param g defines the green component to read from
  3674. * @param b defines the blue component to read from
  3675. * @returns the current Color3 object
  3676. */
  3677. copyFromFloats(r: number, g: number, b: number): Color3;
  3678. /**
  3679. * Updates the Color3 rgb values from the given floats
  3680. * @param r defines the red component to read from
  3681. * @param g defines the green component to read from
  3682. * @param b defines the blue component to read from
  3683. * @returns the current Color3 object
  3684. */
  3685. set(r: number, g: number, b: number): Color3;
  3686. /**
  3687. * Compute the Color3 hexadecimal code as a string
  3688. * @returns a string containing the hexadecimal representation of the Color3 object
  3689. */
  3690. toHexString(): string;
  3691. /**
  3692. * Computes a new Color3 converted from the current one to linear space
  3693. * @returns a new Color3 object
  3694. */
  3695. toLinearSpace(): Color3;
  3696. /**
  3697. * Converts current color in rgb space to HSV values
  3698. * @returns a new color3 representing the HSV values
  3699. */
  3700. toHSV(): Color3;
  3701. /**
  3702. * Converts current color in rgb space to HSV values
  3703. * @param result defines the Color3 where to store the HSV values
  3704. */
  3705. toHSVToRef(result: Color3): void;
  3706. /**
  3707. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3708. * @param convertedColor defines the Color3 object where to store the linear space version
  3709. * @returns the unmodified Color3
  3710. */
  3711. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3712. /**
  3713. * Computes a new Color3 converted from the current one to gamma space
  3714. * @returns a new Color3 object
  3715. */
  3716. toGammaSpace(): Color3;
  3717. /**
  3718. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3719. * @param convertedColor defines the Color3 object where to store the gamma space version
  3720. * @returns the unmodified Color3
  3721. */
  3722. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3723. private static _BlackReadOnly;
  3724. /**
  3725. * Convert Hue, saturation and value to a Color3 (RGB)
  3726. * @param hue defines the hue
  3727. * @param saturation defines the saturation
  3728. * @param value defines the value
  3729. * @param result defines the Color3 where to store the RGB values
  3730. */
  3731. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3732. /**
  3733. * Creates a new Color3 from the string containing valid hexadecimal values
  3734. * @param hex defines a string containing valid hexadecimal values
  3735. * @returns a new Color3 object
  3736. */
  3737. static FromHexString(hex: string): Color3;
  3738. /**
  3739. * Creates a new Color3 from the starting index of the given array
  3740. * @param array defines the source array
  3741. * @param offset defines an offset in the source array
  3742. * @returns a new Color3 object
  3743. */
  3744. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3745. /**
  3746. * Creates a new Color3 from integer values (< 256)
  3747. * @param r defines the red component to read from (value between 0 and 255)
  3748. * @param g defines the green component to read from (value between 0 and 255)
  3749. * @param b defines the blue component to read from (value between 0 and 255)
  3750. * @returns a new Color3 object
  3751. */
  3752. static FromInts(r: number, g: number, b: number): Color3;
  3753. /**
  3754. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3755. * @param start defines the start Color3 value
  3756. * @param end defines the end Color3 value
  3757. * @param amount defines the gradient value between start and end
  3758. * @returns a new Color3 object
  3759. */
  3760. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3761. /**
  3762. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3763. * @param left defines the start value
  3764. * @param right defines the end value
  3765. * @param amount defines the gradient factor
  3766. * @param result defines the Color3 object where to store the result
  3767. */
  3768. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3769. /**
  3770. * Returns a Color3 value containing a red color
  3771. * @returns a new Color3 object
  3772. */
  3773. static Red(): Color3;
  3774. /**
  3775. * Returns a Color3 value containing a green color
  3776. * @returns a new Color3 object
  3777. */
  3778. static Green(): Color3;
  3779. /**
  3780. * Returns a Color3 value containing a blue color
  3781. * @returns a new Color3 object
  3782. */
  3783. static Blue(): Color3;
  3784. /**
  3785. * Returns a Color3 value containing a black color
  3786. * @returns a new Color3 object
  3787. */
  3788. static Black(): Color3;
  3789. /**
  3790. * Gets a Color3 value containing a black color that must not be updated
  3791. */
  3792. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3793. /**
  3794. * Returns a Color3 value containing a white color
  3795. * @returns a new Color3 object
  3796. */
  3797. static White(): Color3;
  3798. /**
  3799. * Returns a Color3 value containing a purple color
  3800. * @returns a new Color3 object
  3801. */
  3802. static Purple(): Color3;
  3803. /**
  3804. * Returns a Color3 value containing a magenta color
  3805. * @returns a new Color3 object
  3806. */
  3807. static Magenta(): Color3;
  3808. /**
  3809. * Returns a Color3 value containing a yellow color
  3810. * @returns a new Color3 object
  3811. */
  3812. static Yellow(): Color3;
  3813. /**
  3814. * Returns a Color3 value containing a gray color
  3815. * @returns a new Color3 object
  3816. */
  3817. static Gray(): Color3;
  3818. /**
  3819. * Returns a Color3 value containing a teal color
  3820. * @returns a new Color3 object
  3821. */
  3822. static Teal(): Color3;
  3823. /**
  3824. * Returns a Color3 value containing a random color
  3825. * @returns a new Color3 object
  3826. */
  3827. static Random(): Color3;
  3828. }
  3829. /**
  3830. * Class used to hold a RBGA color
  3831. */
  3832. export class Color4 {
  3833. /**
  3834. * Defines the red component (between 0 and 1, default is 0)
  3835. */
  3836. r: number;
  3837. /**
  3838. * Defines the green component (between 0 and 1, default is 0)
  3839. */
  3840. g: number;
  3841. /**
  3842. * Defines the blue component (between 0 and 1, default is 0)
  3843. */
  3844. b: number;
  3845. /**
  3846. * Defines the alpha component (between 0 and 1, default is 1)
  3847. */
  3848. a: number;
  3849. /**
  3850. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3851. * @param r defines the red component (between 0 and 1, default is 0)
  3852. * @param g defines the green component (between 0 and 1, default is 0)
  3853. * @param b defines the blue component (between 0 and 1, default is 0)
  3854. * @param a defines the alpha component (between 0 and 1, default is 1)
  3855. */
  3856. constructor(
  3857. /**
  3858. * Defines the red component (between 0 and 1, default is 0)
  3859. */
  3860. r?: number,
  3861. /**
  3862. * Defines the green component (between 0 and 1, default is 0)
  3863. */
  3864. g?: number,
  3865. /**
  3866. * Defines the blue component (between 0 and 1, default is 0)
  3867. */
  3868. b?: number,
  3869. /**
  3870. * Defines the alpha component (between 0 and 1, default is 1)
  3871. */
  3872. a?: number);
  3873. /**
  3874. * Adds in place the given Color4 values to the current Color4 object
  3875. * @param right defines the second operand
  3876. * @returns the current updated Color4 object
  3877. */
  3878. addInPlace(right: DeepImmutable<Color4>): Color4;
  3879. /**
  3880. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3881. * @returns the new array
  3882. */
  3883. asArray(): number[];
  3884. /**
  3885. * Stores from the starting index in the given array the Color4 successive values
  3886. * @param array defines the array where to store the r,g,b components
  3887. * @param index defines an optional index in the target array to define where to start storing values
  3888. * @returns the current Color4 object
  3889. */
  3890. toArray(array: number[], index?: number): Color4;
  3891. /**
  3892. * Determines equality between Color4 objects
  3893. * @param otherColor defines the second operand
  3894. * @returns true if the rgba values are equal to the given ones
  3895. */
  3896. equals(otherColor: DeepImmutable<Color4>): boolean;
  3897. /**
  3898. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3899. * @param right defines the second operand
  3900. * @returns a new Color4 object
  3901. */
  3902. add(right: DeepImmutable<Color4>): Color4;
  3903. /**
  3904. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3905. * @param right defines the second operand
  3906. * @returns a new Color4 object
  3907. */
  3908. subtract(right: DeepImmutable<Color4>): Color4;
  3909. /**
  3910. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3911. * @param right defines the second operand
  3912. * @param result defines the Color4 object where to store the result
  3913. * @returns the current Color4 object
  3914. */
  3915. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3916. /**
  3917. * Creates a new Color4 with the current Color4 values multiplied by scale
  3918. * @param scale defines the scaling factor to apply
  3919. * @returns a new Color4 object
  3920. */
  3921. scale(scale: number): Color4;
  3922. /**
  3923. * Multiplies the current Color4 values by scale and stores the result in "result"
  3924. * @param scale defines the scaling factor to apply
  3925. * @param result defines the Color4 object where to store the result
  3926. * @returns the current unmodified Color4
  3927. */
  3928. scaleToRef(scale: number, result: Color4): Color4;
  3929. /**
  3930. * Scale the current Color4 values by a factor and add the result to a given Color4
  3931. * @param scale defines the scale factor
  3932. * @param result defines the Color4 object where to store the result
  3933. * @returns the unmodified current Color4
  3934. */
  3935. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3936. /**
  3937. * Clamps the rgb values by the min and max values and stores the result into "result"
  3938. * @param min defines minimum clamping value (default is 0)
  3939. * @param max defines maximum clamping value (default is 1)
  3940. * @param result defines color to store the result into.
  3941. * @returns the cuurent Color4
  3942. */
  3943. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3944. /**
  3945. * Multipy an Color4 value by another and return a new Color4 object
  3946. * @param color defines the Color4 value to multiply by
  3947. * @returns a new Color4 object
  3948. */
  3949. multiply(color: Color4): Color4;
  3950. /**
  3951. * Multipy a Color4 value by another and push the result in a reference value
  3952. * @param color defines the Color4 value to multiply by
  3953. * @param result defines the Color4 to fill the result in
  3954. * @returns the result Color4
  3955. */
  3956. multiplyToRef(color: Color4, result: Color4): Color4;
  3957. /**
  3958. * Creates a string with the Color4 current values
  3959. * @returns the string representation of the Color4 object
  3960. */
  3961. toString(): string;
  3962. /**
  3963. * Returns the string "Color4"
  3964. * @returns "Color4"
  3965. */
  3966. getClassName(): string;
  3967. /**
  3968. * Compute the Color4 hash code
  3969. * @returns an unique number that can be used to hash Color4 objects
  3970. */
  3971. getHashCode(): number;
  3972. /**
  3973. * Creates a new Color4 copied from the current one
  3974. * @returns a new Color4 object
  3975. */
  3976. clone(): Color4;
  3977. /**
  3978. * Copies the given Color4 values into the current one
  3979. * @param source defines the source Color4 object
  3980. * @returns the current updated Color4 object
  3981. */
  3982. copyFrom(source: Color4): Color4;
  3983. /**
  3984. * Copies the given float values into the current one
  3985. * @param r defines the red component to read from
  3986. * @param g defines the green component to read from
  3987. * @param b defines the blue component to read from
  3988. * @param a defines the alpha component to read from
  3989. * @returns the current updated Color4 object
  3990. */
  3991. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3992. /**
  3993. * Copies the given float values into the current one
  3994. * @param r defines the red component to read from
  3995. * @param g defines the green component to read from
  3996. * @param b defines the blue component to read from
  3997. * @param a defines the alpha component to read from
  3998. * @returns the current updated Color4 object
  3999. */
  4000. set(r: number, g: number, b: number, a: number): Color4;
  4001. /**
  4002. * Compute the Color4 hexadecimal code as a string
  4003. * @returns a string containing the hexadecimal representation of the Color4 object
  4004. */
  4005. toHexString(): string;
  4006. /**
  4007. * Computes a new Color4 converted from the current one to linear space
  4008. * @returns a new Color4 object
  4009. */
  4010. toLinearSpace(): Color4;
  4011. /**
  4012. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4013. * @param convertedColor defines the Color4 object where to store the linear space version
  4014. * @returns the unmodified Color4
  4015. */
  4016. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4017. /**
  4018. * Computes a new Color4 converted from the current one to gamma space
  4019. * @returns a new Color4 object
  4020. */
  4021. toGammaSpace(): Color4;
  4022. /**
  4023. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4024. * @param convertedColor defines the Color4 object where to store the gamma space version
  4025. * @returns the unmodified Color4
  4026. */
  4027. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4028. /**
  4029. * Creates a new Color4 from the string containing valid hexadecimal values
  4030. * @param hex defines a string containing valid hexadecimal values
  4031. * @returns a new Color4 object
  4032. */
  4033. static FromHexString(hex: string): Color4;
  4034. /**
  4035. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4036. * @param left defines the start value
  4037. * @param right defines the end value
  4038. * @param amount defines the gradient factor
  4039. * @returns a new Color4 object
  4040. */
  4041. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4042. /**
  4043. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4044. * @param left defines the start value
  4045. * @param right defines the end value
  4046. * @param amount defines the gradient factor
  4047. * @param result defines the Color4 object where to store data
  4048. */
  4049. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4050. /**
  4051. * Creates a new Color4 from a Color3 and an alpha value
  4052. * @param color3 defines the source Color3 to read from
  4053. * @param alpha defines the alpha component (1.0 by default)
  4054. * @returns a new Color4 object
  4055. */
  4056. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4057. /**
  4058. * Creates a new Color4 from the starting index element of the given array
  4059. * @param array defines the source array to read from
  4060. * @param offset defines the offset in the source array
  4061. * @returns a new Color4 object
  4062. */
  4063. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4064. /**
  4065. * Creates a new Color3 from integer values (< 256)
  4066. * @param r defines the red component to read from (value between 0 and 255)
  4067. * @param g defines the green component to read from (value between 0 and 255)
  4068. * @param b defines the blue component to read from (value between 0 and 255)
  4069. * @param a defines the alpha component to read from (value between 0 and 255)
  4070. * @returns a new Color3 object
  4071. */
  4072. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4073. /**
  4074. * Check the content of a given array and convert it to an array containing RGBA data
  4075. * If the original array was already containing count * 4 values then it is returned directly
  4076. * @param colors defines the array to check
  4077. * @param count defines the number of RGBA data to expect
  4078. * @returns an array containing count * 4 values (RGBA)
  4079. */
  4080. static CheckColors4(colors: number[], count: number): number[];
  4081. }
  4082. /**
  4083. * @hidden
  4084. */
  4085. export class TmpColors {
  4086. static Color3: Color3[];
  4087. static Color4: Color4[];
  4088. }
  4089. }
  4090. declare module BABYLON {
  4091. /**
  4092. * Class representing spherical harmonics coefficients to the 3rd degree
  4093. */
  4094. export class SphericalHarmonics {
  4095. /**
  4096. * Defines whether or not the harmonics have been prescaled for rendering.
  4097. */
  4098. preScaled: boolean;
  4099. /**
  4100. * The l0,0 coefficients of the spherical harmonics
  4101. */
  4102. l00: Vector3;
  4103. /**
  4104. * The l1,-1 coefficients of the spherical harmonics
  4105. */
  4106. l1_1: Vector3;
  4107. /**
  4108. * The l1,0 coefficients of the spherical harmonics
  4109. */
  4110. l10: Vector3;
  4111. /**
  4112. * The l1,1 coefficients of the spherical harmonics
  4113. */
  4114. l11: Vector3;
  4115. /**
  4116. * The l2,-2 coefficients of the spherical harmonics
  4117. */
  4118. l2_2: Vector3;
  4119. /**
  4120. * The l2,-1 coefficients of the spherical harmonics
  4121. */
  4122. l2_1: Vector3;
  4123. /**
  4124. * The l2,0 coefficients of the spherical harmonics
  4125. */
  4126. l20: Vector3;
  4127. /**
  4128. * The l2,1 coefficients of the spherical harmonics
  4129. */
  4130. l21: Vector3;
  4131. /**
  4132. * The l2,2 coefficients of the spherical harmonics
  4133. */
  4134. l22: Vector3;
  4135. /**
  4136. * Adds a light to the spherical harmonics
  4137. * @param direction the direction of the light
  4138. * @param color the color of the light
  4139. * @param deltaSolidAngle the delta solid angle of the light
  4140. */
  4141. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4142. /**
  4143. * Scales the spherical harmonics by the given amount
  4144. * @param scale the amount to scale
  4145. */
  4146. scaleInPlace(scale: number): void;
  4147. /**
  4148. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4149. *
  4150. * ```
  4151. * E_lm = A_l * L_lm
  4152. * ```
  4153. *
  4154. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4155. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4156. * the scaling factors are given in equation 9.
  4157. */
  4158. convertIncidentRadianceToIrradiance(): void;
  4159. /**
  4160. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4161. *
  4162. * ```
  4163. * L = (1/pi) * E * rho
  4164. * ```
  4165. *
  4166. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4167. */
  4168. convertIrradianceToLambertianRadiance(): void;
  4169. /**
  4170. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4171. * required operations at run time.
  4172. *
  4173. * This is simply done by scaling back the SH with Ylm constants parameter.
  4174. * The trigonometric part being applied by the shader at run time.
  4175. */
  4176. preScaleForRendering(): void;
  4177. /**
  4178. * Constructs a spherical harmonics from an array.
  4179. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4180. * @returns the spherical harmonics
  4181. */
  4182. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4183. /**
  4184. * Gets the spherical harmonics from polynomial
  4185. * @param polynomial the spherical polynomial
  4186. * @returns the spherical harmonics
  4187. */
  4188. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4189. }
  4190. /**
  4191. * Class representing spherical polynomial coefficients to the 3rd degree
  4192. */
  4193. export class SphericalPolynomial {
  4194. private _harmonics;
  4195. /**
  4196. * The spherical harmonics used to create the polynomials.
  4197. */
  4198. readonly preScaledHarmonics: SphericalHarmonics;
  4199. /**
  4200. * The x coefficients of the spherical polynomial
  4201. */
  4202. x: Vector3;
  4203. /**
  4204. * The y coefficients of the spherical polynomial
  4205. */
  4206. y: Vector3;
  4207. /**
  4208. * The z coefficients of the spherical polynomial
  4209. */
  4210. z: Vector3;
  4211. /**
  4212. * The xx coefficients of the spherical polynomial
  4213. */
  4214. xx: Vector3;
  4215. /**
  4216. * The yy coefficients of the spherical polynomial
  4217. */
  4218. yy: Vector3;
  4219. /**
  4220. * The zz coefficients of the spherical polynomial
  4221. */
  4222. zz: Vector3;
  4223. /**
  4224. * The xy coefficients of the spherical polynomial
  4225. */
  4226. xy: Vector3;
  4227. /**
  4228. * The yz coefficients of the spherical polynomial
  4229. */
  4230. yz: Vector3;
  4231. /**
  4232. * The zx coefficients of the spherical polynomial
  4233. */
  4234. zx: Vector3;
  4235. /**
  4236. * Adds an ambient color to the spherical polynomial
  4237. * @param color the color to add
  4238. */
  4239. addAmbient(color: Color3): void;
  4240. /**
  4241. * Scales the spherical polynomial by the given amount
  4242. * @param scale the amount to scale
  4243. */
  4244. scaleInPlace(scale: number): void;
  4245. /**
  4246. * Gets the spherical polynomial from harmonics
  4247. * @param harmonics the spherical harmonics
  4248. * @returns the spherical polynomial
  4249. */
  4250. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4251. /**
  4252. * Constructs a spherical polynomial from an array.
  4253. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4254. * @returns the spherical polynomial
  4255. */
  4256. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4257. }
  4258. }
  4259. declare module BABYLON {
  4260. /**
  4261. * Define options used to create a render target texture
  4262. */
  4263. export class RenderTargetCreationOptions {
  4264. /**
  4265. * Specifies is mipmaps must be generated
  4266. */
  4267. generateMipMaps?: boolean;
  4268. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4269. generateDepthBuffer?: boolean;
  4270. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4271. generateStencilBuffer?: boolean;
  4272. /** Defines texture type (int by default) */
  4273. type?: number;
  4274. /** Defines sampling mode (trilinear by default) */
  4275. samplingMode?: number;
  4276. /** Defines format (RGBA by default) */
  4277. format?: number;
  4278. }
  4279. }
  4280. declare module BABYLON {
  4281. /**
  4282. * @hidden
  4283. **/
  4284. export class _TimeToken {
  4285. _startTimeQuery: Nullable<WebGLQuery>;
  4286. _endTimeQuery: Nullable<WebGLQuery>;
  4287. _timeElapsedQuery: Nullable<WebGLQuery>;
  4288. _timeElapsedQueryEnded: boolean;
  4289. }
  4290. }
  4291. declare module BABYLON {
  4292. /** Defines the cross module used constants to avoid circular dependncies */
  4293. export class Constants {
  4294. /** Defines that alpha blending is disabled */
  4295. static readonly ALPHA_DISABLE: number;
  4296. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4297. static readonly ALPHA_ADD: number;
  4298. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4299. static readonly ALPHA_COMBINE: number;
  4300. /** Defines that alpha blending to DEST - SRC * DEST */
  4301. static readonly ALPHA_SUBTRACT: number;
  4302. /** Defines that alpha blending to SRC * DEST */
  4303. static readonly ALPHA_MULTIPLY: number;
  4304. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4305. static readonly ALPHA_MAXIMIZED: number;
  4306. /** Defines that alpha blending to SRC + DEST */
  4307. static readonly ALPHA_ONEONE: number;
  4308. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4309. static readonly ALPHA_PREMULTIPLIED: number;
  4310. /**
  4311. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4312. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4313. */
  4314. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4315. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4316. static readonly ALPHA_INTERPOLATE: number;
  4317. /**
  4318. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4319. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4320. */
  4321. static readonly ALPHA_SCREENMODE: number;
  4322. /**
  4323. * Defines that alpha blending to SRC + DST
  4324. * Alpha will be set to SRC ALPHA + DST ALPHA
  4325. */
  4326. static readonly ALPHA_ONEONE_ONEONE: number;
  4327. /**
  4328. * Defines that alpha blending to SRC * DST ALPHA + DST
  4329. * Alpha will be set to 0
  4330. */
  4331. static readonly ALPHA_ALPHATOCOLOR: number;
  4332. /**
  4333. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4334. */
  4335. static readonly ALPHA_REVERSEONEMINUS: number;
  4336. /**
  4337. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4338. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4339. */
  4340. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4341. /**
  4342. * Defines that alpha blending to SRC + DST
  4343. * Alpha will be set to SRC ALPHA
  4344. */
  4345. static readonly ALPHA_ONEONE_ONEZERO: number;
  4346. /** Defines that alpha blending equation a SUM */
  4347. static readonly ALPHA_EQUATION_ADD: number;
  4348. /** Defines that alpha blending equation a SUBSTRACTION */
  4349. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4350. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4351. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4352. /** Defines that alpha blending equation a MAX operation */
  4353. static readonly ALPHA_EQUATION_MAX: number;
  4354. /** Defines that alpha blending equation a MIN operation */
  4355. static readonly ALPHA_EQUATION_MIN: number;
  4356. /**
  4357. * Defines that alpha blending equation a DARKEN operation:
  4358. * It takes the min of the src and sums the alpha channels.
  4359. */
  4360. static readonly ALPHA_EQUATION_DARKEN: number;
  4361. /** Defines that the ressource is not delayed*/
  4362. static readonly DELAYLOADSTATE_NONE: number;
  4363. /** Defines that the ressource was successfully delay loaded */
  4364. static readonly DELAYLOADSTATE_LOADED: number;
  4365. /** Defines that the ressource is currently delay loading */
  4366. static readonly DELAYLOADSTATE_LOADING: number;
  4367. /** Defines that the ressource is delayed and has not started loading */
  4368. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4370. static readonly NEVER: number;
  4371. /** 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 */
  4372. static readonly ALWAYS: number;
  4373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4374. static readonly LESS: number;
  4375. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4376. static readonly EQUAL: number;
  4377. /** 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 */
  4378. static readonly LEQUAL: number;
  4379. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4380. static readonly GREATER: number;
  4381. /** 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 */
  4382. static readonly GEQUAL: number;
  4383. /** 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 */
  4384. static readonly NOTEQUAL: number;
  4385. /** Passed to stencilOperation to specify that stencil value must be kept */
  4386. static readonly KEEP: number;
  4387. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4388. static readonly REPLACE: number;
  4389. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4390. static readonly INCR: number;
  4391. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4392. static readonly DECR: number;
  4393. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4394. static readonly INVERT: number;
  4395. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4396. static readonly INCR_WRAP: number;
  4397. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4398. static readonly DECR_WRAP: number;
  4399. /** Texture is not repeating outside of 0..1 UVs */
  4400. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4401. /** Texture is repeating outside of 0..1 UVs */
  4402. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4403. /** Texture is repeating and mirrored */
  4404. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4405. /** ALPHA */
  4406. static readonly TEXTUREFORMAT_ALPHA: number;
  4407. /** LUMINANCE */
  4408. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4409. /** LUMINANCE_ALPHA */
  4410. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4411. /** RGB */
  4412. static readonly TEXTUREFORMAT_RGB: number;
  4413. /** RGBA */
  4414. static readonly TEXTUREFORMAT_RGBA: number;
  4415. /** RED */
  4416. static readonly TEXTUREFORMAT_RED: number;
  4417. /** RED (2nd reference) */
  4418. static readonly TEXTUREFORMAT_R: number;
  4419. /** RG */
  4420. static readonly TEXTUREFORMAT_RG: number;
  4421. /** RED_INTEGER */
  4422. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4423. /** RED_INTEGER (2nd reference) */
  4424. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4425. /** RG_INTEGER */
  4426. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4427. /** RGB_INTEGER */
  4428. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4429. /** RGBA_INTEGER */
  4430. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4431. /** UNSIGNED_BYTE */
  4432. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4433. /** UNSIGNED_BYTE (2nd reference) */
  4434. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4435. /** FLOAT */
  4436. static readonly TEXTURETYPE_FLOAT: number;
  4437. /** HALF_FLOAT */
  4438. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4439. /** BYTE */
  4440. static readonly TEXTURETYPE_BYTE: number;
  4441. /** SHORT */
  4442. static readonly TEXTURETYPE_SHORT: number;
  4443. /** UNSIGNED_SHORT */
  4444. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4445. /** INT */
  4446. static readonly TEXTURETYPE_INT: number;
  4447. /** UNSIGNED_INT */
  4448. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4449. /** UNSIGNED_SHORT_4_4_4_4 */
  4450. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4451. /** UNSIGNED_SHORT_5_5_5_1 */
  4452. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4453. /** UNSIGNED_SHORT_5_6_5 */
  4454. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4455. /** UNSIGNED_INT_2_10_10_10_REV */
  4456. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4457. /** UNSIGNED_INT_24_8 */
  4458. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4459. /** UNSIGNED_INT_10F_11F_11F_REV */
  4460. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4461. /** UNSIGNED_INT_5_9_9_9_REV */
  4462. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4463. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4464. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4465. /** nearest is mag = nearest and min = nearest and mip = linear */
  4466. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4468. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4469. /** Trilinear is mag = linear and min = linear and mip = linear */
  4470. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4471. /** nearest is mag = nearest and min = nearest and mip = linear */
  4472. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4473. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4474. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4475. /** Trilinear is mag = linear and min = linear and mip = linear */
  4476. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4477. /** mag = nearest and min = nearest and mip = nearest */
  4478. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4479. /** mag = nearest and min = linear and mip = nearest */
  4480. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4481. /** mag = nearest and min = linear and mip = linear */
  4482. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4483. /** mag = nearest and min = linear and mip = none */
  4484. static readonly TEXTURE_NEAREST_LINEAR: number;
  4485. /** mag = nearest and min = nearest and mip = none */
  4486. static readonly TEXTURE_NEAREST_NEAREST: number;
  4487. /** mag = linear and min = nearest and mip = nearest */
  4488. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4489. /** mag = linear and min = nearest and mip = linear */
  4490. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4491. /** mag = linear and min = linear and mip = none */
  4492. static readonly TEXTURE_LINEAR_LINEAR: number;
  4493. /** mag = linear and min = nearest and mip = none */
  4494. static readonly TEXTURE_LINEAR_NEAREST: number;
  4495. /** Explicit coordinates mode */
  4496. static readonly TEXTURE_EXPLICIT_MODE: number;
  4497. /** Spherical coordinates mode */
  4498. static readonly TEXTURE_SPHERICAL_MODE: number;
  4499. /** Planar coordinates mode */
  4500. static readonly TEXTURE_PLANAR_MODE: number;
  4501. /** Cubic coordinates mode */
  4502. static readonly TEXTURE_CUBIC_MODE: number;
  4503. /** Projection coordinates mode */
  4504. static readonly TEXTURE_PROJECTION_MODE: number;
  4505. /** Skybox coordinates mode */
  4506. static readonly TEXTURE_SKYBOX_MODE: number;
  4507. /** Inverse Cubic coordinates mode */
  4508. static readonly TEXTURE_INVCUBIC_MODE: number;
  4509. /** Equirectangular coordinates mode */
  4510. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4511. /** Equirectangular Fixed coordinates mode */
  4512. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4513. /** Equirectangular Fixed Mirrored coordinates mode */
  4514. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4515. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4516. static readonly SCALEMODE_FLOOR: number;
  4517. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4518. static readonly SCALEMODE_NEAREST: number;
  4519. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4520. static readonly SCALEMODE_CEILING: number;
  4521. /**
  4522. * The dirty texture flag value
  4523. */
  4524. static readonly MATERIAL_TextureDirtyFlag: number;
  4525. /**
  4526. * The dirty light flag value
  4527. */
  4528. static readonly MATERIAL_LightDirtyFlag: number;
  4529. /**
  4530. * The dirty fresnel flag value
  4531. */
  4532. static readonly MATERIAL_FresnelDirtyFlag: number;
  4533. /**
  4534. * The dirty attribute flag value
  4535. */
  4536. static readonly MATERIAL_AttributesDirtyFlag: number;
  4537. /**
  4538. * The dirty misc flag value
  4539. */
  4540. static readonly MATERIAL_MiscDirtyFlag: number;
  4541. /**
  4542. * The all dirty flag value
  4543. */
  4544. static readonly MATERIAL_AllDirtyFlag: number;
  4545. /**
  4546. * Returns the triangle fill mode
  4547. */
  4548. static readonly MATERIAL_TriangleFillMode: number;
  4549. /**
  4550. * Returns the wireframe mode
  4551. */
  4552. static readonly MATERIAL_WireFrameFillMode: number;
  4553. /**
  4554. * Returns the point fill mode
  4555. */
  4556. static readonly MATERIAL_PointFillMode: number;
  4557. /**
  4558. * Returns the point list draw mode
  4559. */
  4560. static readonly MATERIAL_PointListDrawMode: number;
  4561. /**
  4562. * Returns the line list draw mode
  4563. */
  4564. static readonly MATERIAL_LineListDrawMode: number;
  4565. /**
  4566. * Returns the line loop draw mode
  4567. */
  4568. static readonly MATERIAL_LineLoopDrawMode: number;
  4569. /**
  4570. * Returns the line strip draw mode
  4571. */
  4572. static readonly MATERIAL_LineStripDrawMode: number;
  4573. /**
  4574. * Returns the triangle strip draw mode
  4575. */
  4576. static readonly MATERIAL_TriangleStripDrawMode: number;
  4577. /**
  4578. * Returns the triangle fan draw mode
  4579. */
  4580. static readonly MATERIAL_TriangleFanDrawMode: number;
  4581. /**
  4582. * Stores the clock-wise side orientation
  4583. */
  4584. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4585. /**
  4586. * Stores the counter clock-wise side orientation
  4587. */
  4588. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4589. /**
  4590. * Nothing
  4591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4592. */
  4593. static readonly ACTION_NothingTrigger: number;
  4594. /**
  4595. * On pick
  4596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4597. */
  4598. static readonly ACTION_OnPickTrigger: number;
  4599. /**
  4600. * On left pick
  4601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4602. */
  4603. static readonly ACTION_OnLeftPickTrigger: number;
  4604. /**
  4605. * On right pick
  4606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4607. */
  4608. static readonly ACTION_OnRightPickTrigger: number;
  4609. /**
  4610. * On center pick
  4611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4612. */
  4613. static readonly ACTION_OnCenterPickTrigger: number;
  4614. /**
  4615. * On pick down
  4616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4617. */
  4618. static readonly ACTION_OnPickDownTrigger: number;
  4619. /**
  4620. * On double pick
  4621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4622. */
  4623. static readonly ACTION_OnDoublePickTrigger: number;
  4624. /**
  4625. * On pick up
  4626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4627. */
  4628. static readonly ACTION_OnPickUpTrigger: number;
  4629. /**
  4630. * On pick out.
  4631. * This trigger will only be raised if you also declared a OnPickDown
  4632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4633. */
  4634. static readonly ACTION_OnPickOutTrigger: number;
  4635. /**
  4636. * On long press
  4637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4638. */
  4639. static readonly ACTION_OnLongPressTrigger: number;
  4640. /**
  4641. * On pointer over
  4642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4643. */
  4644. static readonly ACTION_OnPointerOverTrigger: number;
  4645. /**
  4646. * On pointer out
  4647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4648. */
  4649. static readonly ACTION_OnPointerOutTrigger: number;
  4650. /**
  4651. * On every frame
  4652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4653. */
  4654. static readonly ACTION_OnEveryFrameTrigger: number;
  4655. /**
  4656. * On intersection enter
  4657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4658. */
  4659. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4660. /**
  4661. * On intersection exit
  4662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4663. */
  4664. static readonly ACTION_OnIntersectionExitTrigger: number;
  4665. /**
  4666. * On key down
  4667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4668. */
  4669. static readonly ACTION_OnKeyDownTrigger: number;
  4670. /**
  4671. * On key up
  4672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4673. */
  4674. static readonly ACTION_OnKeyUpTrigger: number;
  4675. /**
  4676. * Billboard mode will only apply to Y axis
  4677. */
  4678. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4679. /**
  4680. * Billboard mode will apply to all axes
  4681. */
  4682. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4683. /**
  4684. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4685. */
  4686. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4687. /**
  4688. * Gets or sets base Assets URL
  4689. */
  4690. static PARTICLES_BaseAssetsUrl: string;
  4691. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4692. * Test order :
  4693. * Is the bounding sphere outside the frustum ?
  4694. * If not, are the bounding box vertices outside the frustum ?
  4695. * It not, then the cullable object is in the frustum.
  4696. */
  4697. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4698. /** Culling strategy : Bounding Sphere Only.
  4699. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4700. * It's also less accurate than the standard because some not visible objects can still be selected.
  4701. * Test : is the bounding sphere outside the frustum ?
  4702. * If not, then the cullable object is in the frustum.
  4703. */
  4704. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4705. /** Culling strategy : Optimistic Inclusion.
  4706. * This in an inclusion test first, then the standard exclusion test.
  4707. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4708. * 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.
  4709. * Anyway, it's as accurate as the standard strategy.
  4710. * Test :
  4711. * Is the cullable object bounding sphere center in the frustum ?
  4712. * If not, apply the default culling strategy.
  4713. */
  4714. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4715. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4716. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4717. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4718. * 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.
  4719. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4720. * Test :
  4721. * Is the cullable object bounding sphere center in the frustum ?
  4722. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4723. */
  4724. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4725. /**
  4726. * No logging while loading
  4727. */
  4728. static readonly SCENELOADER_NO_LOGGING: number;
  4729. /**
  4730. * Minimal logging while loading
  4731. */
  4732. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4733. /**
  4734. * Summary logging while loading
  4735. */
  4736. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4737. /**
  4738. * Detailled logging while loading
  4739. */
  4740. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4741. }
  4742. }
  4743. declare module BABYLON {
  4744. /**
  4745. * This represents the required contract to create a new type of texture loader.
  4746. */
  4747. export interface IInternalTextureLoader {
  4748. /**
  4749. * Defines wether the loader supports cascade loading the different faces.
  4750. */
  4751. supportCascades: boolean;
  4752. /**
  4753. * This returns if the loader support the current file information.
  4754. * @param extension defines the file extension of the file being loaded
  4755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4756. * @param fallback defines the fallback internal texture if any
  4757. * @param isBase64 defines whether the texture is encoded as a base64
  4758. * @param isBuffer defines whether the texture data are stored as a buffer
  4759. * @returns true if the loader can load the specified file
  4760. */
  4761. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4762. /**
  4763. * Transform the url before loading if required.
  4764. * @param rootUrl the url of the texture
  4765. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4766. * @returns the transformed texture
  4767. */
  4768. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4769. /**
  4770. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4771. * @param rootUrl the url of the texture
  4772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4773. * @returns the fallback texture
  4774. */
  4775. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4776. /**
  4777. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4778. * @param data contains the texture data
  4779. * @param texture defines the BabylonJS internal texture
  4780. * @param createPolynomials will be true if polynomials have been requested
  4781. * @param onLoad defines the callback to trigger once the texture is ready
  4782. * @param onError defines the callback to trigger in case of error
  4783. */
  4784. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4785. /**
  4786. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4787. * @param data contains the texture data
  4788. * @param texture defines the BabylonJS internal texture
  4789. * @param callback defines the method to call once ready to upload
  4790. */
  4791. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4792. }
  4793. }
  4794. declare module BABYLON {
  4795. /**
  4796. * Class used to store and describe the pipeline context associated with an effect
  4797. */
  4798. export interface IPipelineContext {
  4799. /**
  4800. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4801. */
  4802. isAsync: boolean;
  4803. /**
  4804. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4805. */
  4806. isReady: boolean;
  4807. /** @hidden */
  4808. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4809. }
  4810. }
  4811. declare module BABYLON {
  4812. /**
  4813. * Class used to store gfx data (like WebGLBuffer)
  4814. */
  4815. export class DataBuffer {
  4816. /**
  4817. * Gets or sets the number of objects referencing this buffer
  4818. */
  4819. references: number;
  4820. /** Gets or sets the size of the underlying buffer */
  4821. capacity: number;
  4822. /**
  4823. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4824. */
  4825. is32Bits: boolean;
  4826. /**
  4827. * Gets the underlying buffer
  4828. */
  4829. readonly underlyingResource: any;
  4830. }
  4831. }
  4832. declare module BABYLON {
  4833. /** @hidden */
  4834. export interface IShaderProcessor {
  4835. attributeProcessor?: (attribute: string) => string;
  4836. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4837. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4838. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4839. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4840. lineProcessor?: (line: string, isFragment: boolean) => string;
  4841. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4842. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4843. }
  4844. }
  4845. declare module BABYLON {
  4846. /** @hidden */
  4847. export interface ProcessingOptions {
  4848. defines: string[];
  4849. indexParameters: any;
  4850. isFragment: boolean;
  4851. shouldUseHighPrecisionShader: boolean;
  4852. supportsUniformBuffers: boolean;
  4853. shadersRepository: string;
  4854. includesShadersStore: {
  4855. [key: string]: string;
  4856. };
  4857. processor?: IShaderProcessor;
  4858. version: string;
  4859. platformName: string;
  4860. lookForClosingBracketForUniformBuffer?: boolean;
  4861. }
  4862. }
  4863. declare module BABYLON {
  4864. /**
  4865. * Helper to manipulate strings
  4866. */
  4867. export class StringTools {
  4868. /**
  4869. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4870. * @param str Source string
  4871. * @param suffix Suffix to search for in the source string
  4872. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4873. */
  4874. static EndsWith(str: string, suffix: string): boolean;
  4875. /**
  4876. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4877. * @param str Source string
  4878. * @param suffix Suffix to search for in the source string
  4879. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4880. */
  4881. static StartsWith(str: string, suffix: string): boolean;
  4882. }
  4883. }
  4884. declare module BABYLON {
  4885. /** @hidden */
  4886. export class ShaderCodeNode {
  4887. line: string;
  4888. children: ShaderCodeNode[];
  4889. additionalDefineKey?: string;
  4890. additionalDefineValue?: string;
  4891. isValid(preprocessors: {
  4892. [key: string]: string;
  4893. }): boolean;
  4894. process(preprocessors: {
  4895. [key: string]: string;
  4896. }, options: ProcessingOptions): string;
  4897. }
  4898. }
  4899. declare module BABYLON {
  4900. /** @hidden */
  4901. export class ShaderCodeCursor {
  4902. private _lines;
  4903. lineIndex: number;
  4904. readonly currentLine: string;
  4905. readonly canRead: boolean;
  4906. lines: string[];
  4907. }
  4908. }
  4909. declare module BABYLON {
  4910. /** @hidden */
  4911. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4912. process(preprocessors: {
  4913. [key: string]: string;
  4914. }, options: ProcessingOptions): string;
  4915. }
  4916. }
  4917. declare module BABYLON {
  4918. /** @hidden */
  4919. export class ShaderDefineExpression {
  4920. isTrue(preprocessors: {
  4921. [key: string]: string;
  4922. }): boolean;
  4923. }
  4924. }
  4925. declare module BABYLON {
  4926. /** @hidden */
  4927. export class ShaderCodeTestNode extends ShaderCodeNode {
  4928. testExpression: ShaderDefineExpression;
  4929. isValid(preprocessors: {
  4930. [key: string]: string;
  4931. }): boolean;
  4932. }
  4933. }
  4934. declare module BABYLON {
  4935. /** @hidden */
  4936. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4937. define: string;
  4938. not: boolean;
  4939. constructor(define: string, not?: boolean);
  4940. isTrue(preprocessors: {
  4941. [key: string]: string;
  4942. }): boolean;
  4943. }
  4944. }
  4945. declare module BABYLON {
  4946. /** @hidden */
  4947. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4948. leftOperand: ShaderDefineExpression;
  4949. rightOperand: ShaderDefineExpression;
  4950. isTrue(preprocessors: {
  4951. [key: string]: string;
  4952. }): boolean;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /** @hidden */
  4957. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4958. leftOperand: ShaderDefineExpression;
  4959. rightOperand: ShaderDefineExpression;
  4960. isTrue(preprocessors: {
  4961. [key: string]: string;
  4962. }): boolean;
  4963. }
  4964. }
  4965. declare module BABYLON {
  4966. /** @hidden */
  4967. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4968. define: string;
  4969. operand: string;
  4970. testValue: string;
  4971. constructor(define: string, operand: string, testValue: string);
  4972. isTrue(preprocessors: {
  4973. [key: string]: string;
  4974. }): boolean;
  4975. }
  4976. }
  4977. declare module BABYLON {
  4978. /**
  4979. * @ignore
  4980. * Application error to support additional information when loading a file
  4981. */
  4982. export class LoadFileError extends Error {
  4983. /** defines the optional web request */
  4984. request?: WebRequest | undefined;
  4985. private static _setPrototypeOf;
  4986. /**
  4987. * Creates a new LoadFileError
  4988. * @param message defines the message of the error
  4989. * @param request defines the optional web request
  4990. */
  4991. constructor(message: string,
  4992. /** defines the optional web request */
  4993. request?: WebRequest | undefined);
  4994. }
  4995. }
  4996. declare module BABYLON {
  4997. /**
  4998. * Class used to enable access to offline support
  4999. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5000. */
  5001. export interface IOfflineProvider {
  5002. /**
  5003. * Gets a boolean indicating if scene must be saved in the database
  5004. */
  5005. enableSceneOffline: boolean;
  5006. /**
  5007. * Gets a boolean indicating if textures must be saved in the database
  5008. */
  5009. enableTexturesOffline: boolean;
  5010. /**
  5011. * Open the offline support and make it available
  5012. * @param successCallback defines the callback to call on success
  5013. * @param errorCallback defines the callback to call on error
  5014. */
  5015. open(successCallback: () => void, errorCallback: () => void): void;
  5016. /**
  5017. * Loads an image from the offline support
  5018. * @param url defines the url to load from
  5019. * @param image defines the target DOM image
  5020. */
  5021. loadImage(url: string, image: HTMLImageElement): void;
  5022. /**
  5023. * Loads a file from offline support
  5024. * @param url defines the URL to load from
  5025. * @param sceneLoaded defines a callback to call on success
  5026. * @param progressCallBack defines a callback to call when progress changed
  5027. * @param errorCallback defines a callback to call on error
  5028. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5029. */
  5030. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5031. }
  5032. }
  5033. declare module BABYLON {
  5034. /**
  5035. * Class used to help managing file picking and drag'n'drop
  5036. * File Storage
  5037. */
  5038. export class FilesInputStore {
  5039. /**
  5040. * List of files ready to be loaded
  5041. */
  5042. static FilesToLoad: {
  5043. [key: string]: File;
  5044. };
  5045. }
  5046. }
  5047. declare module BABYLON {
  5048. /**
  5049. * Class used to define a retry strategy when error happens while loading assets
  5050. */
  5051. export class RetryStrategy {
  5052. /**
  5053. * Function used to defines an exponential back off strategy
  5054. * @param maxRetries defines the maximum number of retries (3 by default)
  5055. * @param baseInterval defines the interval between retries
  5056. * @returns the strategy function to use
  5057. */
  5058. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * @hidden
  5064. */
  5065. export class FileTools {
  5066. /**
  5067. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5068. */
  5069. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5070. /**
  5071. * Gets or sets the base URL to use to load assets
  5072. */
  5073. static BaseUrl: string;
  5074. /**
  5075. * Default behaviour for cors in the application.
  5076. * It can be a string if the expected behavior is identical in the entire app.
  5077. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5078. */
  5079. static CorsBehavior: string | ((url: string | string[]) => string);
  5080. /**
  5081. * Gets or sets a function used to pre-process url before using them to load assets
  5082. */
  5083. static PreprocessUrl: (url: string) => string;
  5084. /**
  5085. * Removes unwanted characters from an url
  5086. * @param url defines the url to clean
  5087. * @returns the cleaned url
  5088. */
  5089. private static _CleanUrl;
  5090. /**
  5091. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5092. * @param url define the url we are trying
  5093. * @param element define the dom element where to configure the cors policy
  5094. */
  5095. static SetCorsBehavior(url: string | string[], element: {
  5096. crossOrigin: string | null;
  5097. }): void;
  5098. /**
  5099. * Loads an image as an HTMLImageElement.
  5100. * @param input url string, ArrayBuffer, or Blob to load
  5101. * @param onLoad callback called when the image successfully loads
  5102. * @param onError callback called when the image fails to load
  5103. * @param offlineProvider offline provider for caching
  5104. * @returns the HTMLImageElement of the loaded image
  5105. */
  5106. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5107. /**
  5108. * Loads a file
  5109. * @param fileToLoad defines the file to load
  5110. * @param callback defines the callback to call when data is loaded
  5111. * @param progressCallBack defines the callback to call during loading process
  5112. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5113. * @returns a file request object
  5114. */
  5115. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5116. /**
  5117. * Loads a file
  5118. * @param url url string, ArrayBuffer, or Blob to load
  5119. * @param onSuccess callback called when the file successfully loads
  5120. * @param onProgress callback called while file is loading (if the server supports this mode)
  5121. * @param offlineProvider defines the offline provider for caching
  5122. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5123. * @param onError callback called when the file fails to load
  5124. * @returns a file request object
  5125. */
  5126. 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;
  5127. /**
  5128. * Checks if the loaded document was accessed via `file:`-Protocol.
  5129. * @returns boolean
  5130. */
  5131. static IsFileURL(): boolean;
  5132. }
  5133. }
  5134. declare module BABYLON {
  5135. /** @hidden */
  5136. export class ShaderProcessor {
  5137. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5138. private static _ProcessPrecision;
  5139. private static _ExtractOperation;
  5140. private static _BuildSubExpression;
  5141. private static _BuildExpression;
  5142. private static _MoveCursorWithinIf;
  5143. private static _MoveCursor;
  5144. private static _EvaluatePreProcessors;
  5145. private static _PreparePreProcessors;
  5146. private static _ProcessShaderConversion;
  5147. private static _ProcessIncludes;
  5148. }
  5149. }
  5150. declare module BABYLON {
  5151. /**
  5152. * Class used to evalaute queries containing `and` and `or` operators
  5153. */
  5154. export class AndOrNotEvaluator {
  5155. /**
  5156. * Evaluate a query
  5157. * @param query defines the query to evaluate
  5158. * @param evaluateCallback defines the callback used to filter result
  5159. * @returns true if the query matches
  5160. */
  5161. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5162. private static _HandleParenthesisContent;
  5163. private static _SimplifyNegation;
  5164. }
  5165. }
  5166. declare module BABYLON {
  5167. /**
  5168. * Class used to store custom tags
  5169. */
  5170. export class Tags {
  5171. /**
  5172. * Adds support for tags on the given object
  5173. * @param obj defines the object to use
  5174. */
  5175. static EnableFor(obj: any): void;
  5176. /**
  5177. * Removes tags support
  5178. * @param obj defines the object to use
  5179. */
  5180. static DisableFor(obj: any): void;
  5181. /**
  5182. * Gets a boolean indicating if the given object has tags
  5183. * @param obj defines the object to use
  5184. * @returns a boolean
  5185. */
  5186. static HasTags(obj: any): boolean;
  5187. /**
  5188. * Gets the tags available on a given object
  5189. * @param obj defines the object to use
  5190. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5191. * @returns the tags
  5192. */
  5193. static GetTags(obj: any, asString?: boolean): any;
  5194. /**
  5195. * Adds tags to an object
  5196. * @param obj defines the object to use
  5197. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5198. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5199. */
  5200. static AddTagsTo(obj: any, tagsString: string): void;
  5201. /**
  5202. * @hidden
  5203. */
  5204. static _AddTagTo(obj: any, tag: string): void;
  5205. /**
  5206. * Removes specific tags from a specific object
  5207. * @param obj defines the object to use
  5208. * @param tagsString defines the tags to remove
  5209. */
  5210. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5211. /**
  5212. * @hidden
  5213. */
  5214. static _RemoveTagFrom(obj: any, tag: string): void;
  5215. /**
  5216. * Defines if tags hosted on an object match a given query
  5217. * @param obj defines the object to use
  5218. * @param tagsQuery defines the tag query
  5219. * @returns a boolean
  5220. */
  5221. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5222. }
  5223. }
  5224. declare module BABYLON {
  5225. /**
  5226. * Defines potential orientation for back face culling
  5227. */
  5228. export enum Orientation {
  5229. /**
  5230. * Clockwise
  5231. */
  5232. CW = 0,
  5233. /** Counter clockwise */
  5234. CCW = 1
  5235. }
  5236. /** Class used to represent a Bezier curve */
  5237. export class BezierCurve {
  5238. /**
  5239. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5240. * @param t defines the time
  5241. * @param x1 defines the left coordinate on X axis
  5242. * @param y1 defines the left coordinate on Y axis
  5243. * @param x2 defines the right coordinate on X axis
  5244. * @param y2 defines the right coordinate on Y axis
  5245. * @returns the interpolated value
  5246. */
  5247. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5248. }
  5249. /**
  5250. * Defines angle representation
  5251. */
  5252. export class Angle {
  5253. private _radians;
  5254. /**
  5255. * Creates an Angle object of "radians" radians (float).
  5256. * @param radians the angle in radians
  5257. */
  5258. constructor(radians: number);
  5259. /**
  5260. * Get value in degrees
  5261. * @returns the Angle value in degrees (float)
  5262. */
  5263. degrees(): number;
  5264. /**
  5265. * Get value in radians
  5266. * @returns the Angle value in radians (float)
  5267. */
  5268. radians(): number;
  5269. /**
  5270. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5271. * @param a defines first vector
  5272. * @param b defines second vector
  5273. * @returns a new Angle
  5274. */
  5275. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5276. /**
  5277. * Gets a new Angle object from the given float in radians
  5278. * @param radians defines the angle value in radians
  5279. * @returns a new Angle
  5280. */
  5281. static FromRadians(radians: number): Angle;
  5282. /**
  5283. * Gets a new Angle object from the given float in degrees
  5284. * @param degrees defines the angle value in degrees
  5285. * @returns a new Angle
  5286. */
  5287. static FromDegrees(degrees: number): Angle;
  5288. }
  5289. /**
  5290. * This represents an arc in a 2d space.
  5291. */
  5292. export class Arc2 {
  5293. /** Defines the start point of the arc */
  5294. startPoint: Vector2;
  5295. /** Defines the mid point of the arc */
  5296. midPoint: Vector2;
  5297. /** Defines the end point of the arc */
  5298. endPoint: Vector2;
  5299. /**
  5300. * Defines the center point of the arc.
  5301. */
  5302. centerPoint: Vector2;
  5303. /**
  5304. * Defines the radius of the arc.
  5305. */
  5306. radius: number;
  5307. /**
  5308. * Defines the angle of the arc (from mid point to end point).
  5309. */
  5310. angle: Angle;
  5311. /**
  5312. * Defines the start angle of the arc (from start point to middle point).
  5313. */
  5314. startAngle: Angle;
  5315. /**
  5316. * Defines the orientation of the arc (clock wise/counter clock wise).
  5317. */
  5318. orientation: Orientation;
  5319. /**
  5320. * Creates an Arc object from the three given points : start, middle and end.
  5321. * @param startPoint Defines the start point of the arc
  5322. * @param midPoint Defines the midlle point of the arc
  5323. * @param endPoint Defines the end point of the arc
  5324. */
  5325. constructor(
  5326. /** Defines the start point of the arc */
  5327. startPoint: Vector2,
  5328. /** Defines the mid point of the arc */
  5329. midPoint: Vector2,
  5330. /** Defines the end point of the arc */
  5331. endPoint: Vector2);
  5332. }
  5333. /**
  5334. * Represents a 2D path made up of multiple 2D points
  5335. */
  5336. export class Path2 {
  5337. private _points;
  5338. private _length;
  5339. /**
  5340. * If the path start and end point are the same
  5341. */
  5342. closed: boolean;
  5343. /**
  5344. * Creates a Path2 object from the starting 2D coordinates x and y.
  5345. * @param x the starting points x value
  5346. * @param y the starting points y value
  5347. */
  5348. constructor(x: number, y: number);
  5349. /**
  5350. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5351. * @param x the added points x value
  5352. * @param y the added points y value
  5353. * @returns the updated Path2.
  5354. */
  5355. addLineTo(x: number, y: number): Path2;
  5356. /**
  5357. * 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.
  5358. * @param midX middle point x value
  5359. * @param midY middle point y value
  5360. * @param endX end point x value
  5361. * @param endY end point y value
  5362. * @param numberOfSegments (default: 36)
  5363. * @returns the updated Path2.
  5364. */
  5365. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5366. /**
  5367. * Closes the Path2.
  5368. * @returns the Path2.
  5369. */
  5370. close(): Path2;
  5371. /**
  5372. * Gets the sum of the distance between each sequential point in the path
  5373. * @returns the Path2 total length (float).
  5374. */
  5375. length(): number;
  5376. /**
  5377. * Gets the points which construct the path
  5378. * @returns the Path2 internal array of points.
  5379. */
  5380. getPoints(): Vector2[];
  5381. /**
  5382. * Retreives the point at the distance aways from the starting point
  5383. * @param normalizedLengthPosition the length along the path to retreive the point from
  5384. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5385. */
  5386. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5387. /**
  5388. * Creates a new path starting from an x and y position
  5389. * @param x starting x value
  5390. * @param y starting y value
  5391. * @returns a new Path2 starting at the coordinates (x, y).
  5392. */
  5393. static StartingAt(x: number, y: number): Path2;
  5394. }
  5395. /**
  5396. * Represents a 3D path made up of multiple 3D points
  5397. */
  5398. export class Path3D {
  5399. /**
  5400. * an array of Vector3, the curve axis of the Path3D
  5401. */
  5402. path: Vector3[];
  5403. private _curve;
  5404. private _distances;
  5405. private _tangents;
  5406. private _normals;
  5407. private _binormals;
  5408. private _raw;
  5409. /**
  5410. * new Path3D(path, normal, raw)
  5411. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5412. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5413. * @param path an array of Vector3, the curve axis of the Path3D
  5414. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5415. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5416. */
  5417. constructor(
  5418. /**
  5419. * an array of Vector3, the curve axis of the Path3D
  5420. */
  5421. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5422. /**
  5423. * Returns the Path3D array of successive Vector3 designing its curve.
  5424. * @returns the Path3D array of successive Vector3 designing its curve.
  5425. */
  5426. getCurve(): Vector3[];
  5427. /**
  5428. * Returns an array populated with tangent vectors on each Path3D curve point.
  5429. * @returns an array populated with tangent vectors on each Path3D curve point.
  5430. */
  5431. getTangents(): Vector3[];
  5432. /**
  5433. * Returns an array populated with normal vectors on each Path3D curve point.
  5434. * @returns an array populated with normal vectors on each Path3D curve point.
  5435. */
  5436. getNormals(): Vector3[];
  5437. /**
  5438. * Returns an array populated with binormal vectors on each Path3D curve point.
  5439. * @returns an array populated with binormal vectors on each Path3D curve point.
  5440. */
  5441. getBinormals(): Vector3[];
  5442. /**
  5443. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5444. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5445. */
  5446. getDistances(): number[];
  5447. /**
  5448. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5449. * @param path path which all values are copied into the curves points
  5450. * @param firstNormal which should be projected onto the curve
  5451. * @returns the same object updated.
  5452. */
  5453. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5454. private _compute;
  5455. private _getFirstNonNullVector;
  5456. private _getLastNonNullVector;
  5457. private _normalVector;
  5458. }
  5459. /**
  5460. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5461. * A Curve3 is designed from a series of successive Vector3.
  5462. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5463. */
  5464. export class Curve3 {
  5465. private _points;
  5466. private _length;
  5467. /**
  5468. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5469. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5470. * @param v1 (Vector3) the control point
  5471. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5472. * @param nbPoints (integer) the wanted number of points in the curve
  5473. * @returns the created Curve3
  5474. */
  5475. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5476. /**
  5477. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5478. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5479. * @param v1 (Vector3) the first control point
  5480. * @param v2 (Vector3) the second control point
  5481. * @param v3 (Vector3) the end point of the Cubic Bezier
  5482. * @param nbPoints (integer) the wanted number of points in the curve
  5483. * @returns the created Curve3
  5484. */
  5485. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5486. /**
  5487. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5488. * @param p1 (Vector3) the origin point of the Hermite Spline
  5489. * @param t1 (Vector3) the tangent vector at the origin point
  5490. * @param p2 (Vector3) the end point of the Hermite Spline
  5491. * @param t2 (Vector3) the tangent vector at the end point
  5492. * @param nbPoints (integer) the wanted number of points in the curve
  5493. * @returns the created Curve3
  5494. */
  5495. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5496. /**
  5497. * Returns a Curve3 object along a CatmullRom Spline curve :
  5498. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5499. * @param nbPoints (integer) the wanted number of points between each curve control points
  5500. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5501. * @returns the created Curve3
  5502. */
  5503. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5504. /**
  5505. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5506. * A Curve3 is designed from a series of successive Vector3.
  5507. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5508. * @param points points which make up the curve
  5509. */
  5510. constructor(points: Vector3[]);
  5511. /**
  5512. * @returns the Curve3 stored array of successive Vector3
  5513. */
  5514. getPoints(): Vector3[];
  5515. /**
  5516. * @returns the computed length (float) of the curve.
  5517. */
  5518. length(): number;
  5519. /**
  5520. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5521. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5522. * curveA and curveB keep unchanged.
  5523. * @param curve the curve to continue from this curve
  5524. * @returns the newly constructed curve
  5525. */
  5526. continue(curve: DeepImmutable<Curve3>): Curve3;
  5527. private _computeLength;
  5528. }
  5529. }
  5530. declare module BABYLON {
  5531. /**
  5532. * This represents the main contract an easing function should follow.
  5533. * Easing functions are used throughout the animation system.
  5534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5535. */
  5536. export interface IEasingFunction {
  5537. /**
  5538. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5539. * of the easing function.
  5540. * The link below provides some of the most common examples of easing functions.
  5541. * @see https://easings.net/
  5542. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5543. * @returns the corresponding value on the curve defined by the easing function
  5544. */
  5545. ease(gradient: number): number;
  5546. }
  5547. /**
  5548. * Base class used for every default easing function.
  5549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5550. */
  5551. export class EasingFunction implements IEasingFunction {
  5552. /**
  5553. * Interpolation follows the mathematical formula associated with the easing function.
  5554. */
  5555. static readonly EASINGMODE_EASEIN: number;
  5556. /**
  5557. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5558. */
  5559. static readonly EASINGMODE_EASEOUT: number;
  5560. /**
  5561. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5562. */
  5563. static readonly EASINGMODE_EASEINOUT: number;
  5564. private _easingMode;
  5565. /**
  5566. * Sets the easing mode of the current function.
  5567. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5568. */
  5569. setEasingMode(easingMode: number): void;
  5570. /**
  5571. * Gets the current easing mode.
  5572. * @returns the easing mode
  5573. */
  5574. getEasingMode(): number;
  5575. /**
  5576. * @hidden
  5577. */
  5578. easeInCore(gradient: number): number;
  5579. /**
  5580. * Given an input gradient between 0 and 1, this returns the corresponding value
  5581. * of the easing function.
  5582. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5583. * @returns the corresponding value on the curve defined by the easing function
  5584. */
  5585. ease(gradient: number): number;
  5586. }
  5587. /**
  5588. * Easing function with a circle shape (see link below).
  5589. * @see https://easings.net/#easeInCirc
  5590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5591. */
  5592. export class CircleEase extends EasingFunction implements IEasingFunction {
  5593. /** @hidden */
  5594. easeInCore(gradient: number): number;
  5595. }
  5596. /**
  5597. * Easing function with a ease back shape (see link below).
  5598. * @see https://easings.net/#easeInBack
  5599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5600. */
  5601. export class BackEase extends EasingFunction implements IEasingFunction {
  5602. /** Defines the amplitude of the function */
  5603. amplitude: number;
  5604. /**
  5605. * Instantiates a back ease easing
  5606. * @see https://easings.net/#easeInBack
  5607. * @param amplitude Defines the amplitude of the function
  5608. */
  5609. constructor(
  5610. /** Defines the amplitude of the function */
  5611. amplitude?: number);
  5612. /** @hidden */
  5613. easeInCore(gradient: number): number;
  5614. }
  5615. /**
  5616. * Easing function with a bouncing shape (see link below).
  5617. * @see https://easings.net/#easeInBounce
  5618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5619. */
  5620. export class BounceEase extends EasingFunction implements IEasingFunction {
  5621. /** Defines the number of bounces */
  5622. bounces: number;
  5623. /** Defines the amplitude of the bounce */
  5624. bounciness: number;
  5625. /**
  5626. * Instantiates a bounce easing
  5627. * @see https://easings.net/#easeInBounce
  5628. * @param bounces Defines the number of bounces
  5629. * @param bounciness Defines the amplitude of the bounce
  5630. */
  5631. constructor(
  5632. /** Defines the number of bounces */
  5633. bounces?: number,
  5634. /** Defines the amplitude of the bounce */
  5635. bounciness?: number);
  5636. /** @hidden */
  5637. easeInCore(gradient: number): number;
  5638. }
  5639. /**
  5640. * Easing function with a power of 3 shape (see link below).
  5641. * @see https://easings.net/#easeInCubic
  5642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5643. */
  5644. export class CubicEase extends EasingFunction implements IEasingFunction {
  5645. /** @hidden */
  5646. easeInCore(gradient: number): number;
  5647. }
  5648. /**
  5649. * Easing function with an elastic shape (see link below).
  5650. * @see https://easings.net/#easeInElastic
  5651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5652. */
  5653. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5654. /** Defines the number of oscillations*/
  5655. oscillations: number;
  5656. /** Defines the amplitude of the oscillations*/
  5657. springiness: number;
  5658. /**
  5659. * Instantiates an elastic easing function
  5660. * @see https://easings.net/#easeInElastic
  5661. * @param oscillations Defines the number of oscillations
  5662. * @param springiness Defines the amplitude of the oscillations
  5663. */
  5664. constructor(
  5665. /** Defines the number of oscillations*/
  5666. oscillations?: number,
  5667. /** Defines the amplitude of the oscillations*/
  5668. springiness?: number);
  5669. /** @hidden */
  5670. easeInCore(gradient: number): number;
  5671. }
  5672. /**
  5673. * Easing function with an exponential shape (see link below).
  5674. * @see https://easings.net/#easeInExpo
  5675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5676. */
  5677. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5678. /** Defines the exponent of the function */
  5679. exponent: number;
  5680. /**
  5681. * Instantiates an exponential easing function
  5682. * @see https://easings.net/#easeInExpo
  5683. * @param exponent Defines the exponent of the function
  5684. */
  5685. constructor(
  5686. /** Defines the exponent of the function */
  5687. exponent?: number);
  5688. /** @hidden */
  5689. easeInCore(gradient: number): number;
  5690. }
  5691. /**
  5692. * Easing function with a power shape (see link below).
  5693. * @see https://easings.net/#easeInQuad
  5694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5695. */
  5696. export class PowerEase extends EasingFunction implements IEasingFunction {
  5697. /** Defines the power of the function */
  5698. power: number;
  5699. /**
  5700. * Instantiates an power base easing function
  5701. * @see https://easings.net/#easeInQuad
  5702. * @param power Defines the power of the function
  5703. */
  5704. constructor(
  5705. /** Defines the power of the function */
  5706. power?: number);
  5707. /** @hidden */
  5708. easeInCore(gradient: number): number;
  5709. }
  5710. /**
  5711. * Easing function with a power of 2 shape (see link below).
  5712. * @see https://easings.net/#easeInQuad
  5713. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5714. */
  5715. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5716. /** @hidden */
  5717. easeInCore(gradient: number): number;
  5718. }
  5719. /**
  5720. * Easing function with a power of 4 shape (see link below).
  5721. * @see https://easings.net/#easeInQuart
  5722. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5723. */
  5724. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5725. /** @hidden */
  5726. easeInCore(gradient: number): number;
  5727. }
  5728. /**
  5729. * Easing function with a power of 5 shape (see link below).
  5730. * @see https://easings.net/#easeInQuint
  5731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5732. */
  5733. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5734. /** @hidden */
  5735. easeInCore(gradient: number): number;
  5736. }
  5737. /**
  5738. * Easing function with a sin shape (see link below).
  5739. * @see https://easings.net/#easeInSine
  5740. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5741. */
  5742. export class SineEase extends EasingFunction implements IEasingFunction {
  5743. /** @hidden */
  5744. easeInCore(gradient: number): number;
  5745. }
  5746. /**
  5747. * Easing function with a bezier shape (see link below).
  5748. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5749. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5750. */
  5751. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5752. /** Defines the x component of the start tangent in the bezier curve */
  5753. x1: number;
  5754. /** Defines the y component of the start tangent in the bezier curve */
  5755. y1: number;
  5756. /** Defines the x component of the end tangent in the bezier curve */
  5757. x2: number;
  5758. /** Defines the y component of the end tangent in the bezier curve */
  5759. y2: number;
  5760. /**
  5761. * Instantiates a bezier function
  5762. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5763. * @param x1 Defines the x component of the start tangent in the bezier curve
  5764. * @param y1 Defines the y component of the start tangent in the bezier curve
  5765. * @param x2 Defines the x component of the end tangent in the bezier curve
  5766. * @param y2 Defines the y component of the end tangent in the bezier curve
  5767. */
  5768. constructor(
  5769. /** Defines the x component of the start tangent in the bezier curve */
  5770. x1?: number,
  5771. /** Defines the y component of the start tangent in the bezier curve */
  5772. y1?: number,
  5773. /** Defines the x component of the end tangent in the bezier curve */
  5774. x2?: number,
  5775. /** Defines the y component of the end tangent in the bezier curve */
  5776. y2?: number);
  5777. /** @hidden */
  5778. easeInCore(gradient: number): number;
  5779. }
  5780. }
  5781. declare module BABYLON {
  5782. /**
  5783. * Defines an interface which represents an animation key frame
  5784. */
  5785. export interface IAnimationKey {
  5786. /**
  5787. * Frame of the key frame
  5788. */
  5789. frame: number;
  5790. /**
  5791. * Value at the specifies key frame
  5792. */
  5793. value: any;
  5794. /**
  5795. * The input tangent for the cubic hermite spline
  5796. */
  5797. inTangent?: any;
  5798. /**
  5799. * The output tangent for the cubic hermite spline
  5800. */
  5801. outTangent?: any;
  5802. /**
  5803. * The animation interpolation type
  5804. */
  5805. interpolation?: AnimationKeyInterpolation;
  5806. }
  5807. /**
  5808. * Enum for the animation key frame interpolation type
  5809. */
  5810. export enum AnimationKeyInterpolation {
  5811. /**
  5812. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5813. */
  5814. STEP = 1
  5815. }
  5816. }
  5817. declare module BABYLON {
  5818. /**
  5819. * Represents the range of an animation
  5820. */
  5821. export class AnimationRange {
  5822. /**The name of the animation range**/
  5823. name: string;
  5824. /**The starting frame of the animation */
  5825. from: number;
  5826. /**The ending frame of the animation*/
  5827. to: number;
  5828. /**
  5829. * Initializes the range of an animation
  5830. * @param name The name of the animation range
  5831. * @param from The starting frame of the animation
  5832. * @param to The ending frame of the animation
  5833. */
  5834. constructor(
  5835. /**The name of the animation range**/
  5836. name: string,
  5837. /**The starting frame of the animation */
  5838. from: number,
  5839. /**The ending frame of the animation*/
  5840. to: number);
  5841. /**
  5842. * Makes a copy of the animation range
  5843. * @returns A copy of the animation range
  5844. */
  5845. clone(): AnimationRange;
  5846. }
  5847. }
  5848. declare module BABYLON {
  5849. /**
  5850. * Composed of a frame, and an action function
  5851. */
  5852. export class AnimationEvent {
  5853. /** The frame for which the event is triggered **/
  5854. frame: number;
  5855. /** The event to perform when triggered **/
  5856. action: (currentFrame: number) => void;
  5857. /** Specifies if the event should be triggered only once**/
  5858. onlyOnce?: boolean | undefined;
  5859. /**
  5860. * Specifies if the animation event is done
  5861. */
  5862. isDone: boolean;
  5863. /**
  5864. * Initializes the animation event
  5865. * @param frame The frame for which the event is triggered
  5866. * @param action The event to perform when triggered
  5867. * @param onlyOnce Specifies if the event should be triggered only once
  5868. */
  5869. constructor(
  5870. /** The frame for which the event is triggered **/
  5871. frame: number,
  5872. /** The event to perform when triggered **/
  5873. action: (currentFrame: number) => void,
  5874. /** Specifies if the event should be triggered only once**/
  5875. onlyOnce?: boolean | undefined);
  5876. /** @hidden */
  5877. _clone(): AnimationEvent;
  5878. }
  5879. }
  5880. declare module BABYLON {
  5881. /**
  5882. * Interface used to define a behavior
  5883. */
  5884. export interface Behavior<T> {
  5885. /** gets or sets behavior's name */
  5886. name: string;
  5887. /**
  5888. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5889. */
  5890. init(): void;
  5891. /**
  5892. * Called when the behavior is attached to a target
  5893. * @param target defines the target where the behavior is attached to
  5894. */
  5895. attach(target: T): void;
  5896. /**
  5897. * Called when the behavior is detached from its target
  5898. */
  5899. detach(): void;
  5900. }
  5901. /**
  5902. * Interface implemented by classes supporting behaviors
  5903. */
  5904. export interface IBehaviorAware<T> {
  5905. /**
  5906. * Attach a behavior
  5907. * @param behavior defines the behavior to attach
  5908. * @returns the current host
  5909. */
  5910. addBehavior(behavior: Behavior<T>): T;
  5911. /**
  5912. * Remove a behavior from the current object
  5913. * @param behavior defines the behavior to detach
  5914. * @returns the current host
  5915. */
  5916. removeBehavior(behavior: Behavior<T>): T;
  5917. /**
  5918. * Gets a behavior using its name to search
  5919. * @param name defines the name to search
  5920. * @returns the behavior or null if not found
  5921. */
  5922. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5923. }
  5924. }
  5925. declare module BABYLON {
  5926. /**
  5927. * Defines an array and its length.
  5928. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5929. */
  5930. export interface ISmartArrayLike<T> {
  5931. /**
  5932. * The data of the array.
  5933. */
  5934. data: Array<T>;
  5935. /**
  5936. * The active length of the array.
  5937. */
  5938. length: number;
  5939. }
  5940. /**
  5941. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5942. */
  5943. export class SmartArray<T> implements ISmartArrayLike<T> {
  5944. /**
  5945. * The full set of data from the array.
  5946. */
  5947. data: Array<T>;
  5948. /**
  5949. * The active length of the array.
  5950. */
  5951. length: number;
  5952. protected _id: number;
  5953. /**
  5954. * Instantiates a Smart Array.
  5955. * @param capacity defines the default capacity of the array.
  5956. */
  5957. constructor(capacity: number);
  5958. /**
  5959. * Pushes a value at the end of the active data.
  5960. * @param value defines the object to push in the array.
  5961. */
  5962. push(value: T): void;
  5963. /**
  5964. * Iterates over the active data and apply the lambda to them.
  5965. * @param func defines the action to apply on each value.
  5966. */
  5967. forEach(func: (content: T) => void): void;
  5968. /**
  5969. * Sorts the full sets of data.
  5970. * @param compareFn defines the comparison function to apply.
  5971. */
  5972. sort(compareFn: (a: T, b: T) => number): void;
  5973. /**
  5974. * Resets the active data to an empty array.
  5975. */
  5976. reset(): void;
  5977. /**
  5978. * Releases all the data from the array as well as the array.
  5979. */
  5980. dispose(): void;
  5981. /**
  5982. * Concats the active data with a given array.
  5983. * @param array defines the data to concatenate with.
  5984. */
  5985. concat(array: any): void;
  5986. /**
  5987. * Returns the position of a value in the active data.
  5988. * @param value defines the value to find the index for
  5989. * @returns the index if found in the active data otherwise -1
  5990. */
  5991. indexOf(value: T): number;
  5992. /**
  5993. * Returns whether an element is part of the active data.
  5994. * @param value defines the value to look for
  5995. * @returns true if found in the active data otherwise false
  5996. */
  5997. contains(value: T): boolean;
  5998. private static _GlobalId;
  5999. }
  6000. /**
  6001. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6002. * The data in this array can only be present once
  6003. */
  6004. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6005. private _duplicateId;
  6006. /**
  6007. * Pushes a value at the end of the active data.
  6008. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6009. * @param value defines the object to push in the array.
  6010. */
  6011. push(value: T): void;
  6012. /**
  6013. * Pushes a value at the end of the active data.
  6014. * If the data is already present, it won t be added again
  6015. * @param value defines the object to push in the array.
  6016. * @returns true if added false if it was already present
  6017. */
  6018. pushNoDuplicate(value: T): boolean;
  6019. /**
  6020. * Resets the active data to an empty array.
  6021. */
  6022. reset(): void;
  6023. /**
  6024. * Concats the active data with a given array.
  6025. * This ensures no dupplicate will be present in the result.
  6026. * @param array defines the data to concatenate with.
  6027. */
  6028. concatWithNoDuplicate(array: any): void;
  6029. }
  6030. }
  6031. declare module BABYLON {
  6032. /**
  6033. * @ignore
  6034. * This is a list of all the different input types that are available in the application.
  6035. * Fo instance: ArcRotateCameraGamepadInput...
  6036. */
  6037. export var CameraInputTypes: {};
  6038. /**
  6039. * This is the contract to implement in order to create a new input class.
  6040. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6041. */
  6042. export interface ICameraInput<TCamera extends Camera> {
  6043. /**
  6044. * Defines the camera the input is attached to.
  6045. */
  6046. camera: Nullable<TCamera>;
  6047. /**
  6048. * Gets the class name of the current intput.
  6049. * @returns the class name
  6050. */
  6051. getClassName(): string;
  6052. /**
  6053. * Get the friendly name associated with the input class.
  6054. * @returns the input friendly name
  6055. */
  6056. getSimpleName(): string;
  6057. /**
  6058. * Attach the input controls to a specific dom element to get the input from.
  6059. * @param element Defines the element the controls should be listened from
  6060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6061. */
  6062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6063. /**
  6064. * Detach the current controls from the specified dom element.
  6065. * @param element Defines the element to stop listening the inputs from
  6066. */
  6067. detachControl(element: Nullable<HTMLElement>): void;
  6068. /**
  6069. * Update the current camera state depending on the inputs that have been used this frame.
  6070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6071. */
  6072. checkInputs?: () => void;
  6073. }
  6074. /**
  6075. * Represents a map of input types to input instance or input index to input instance.
  6076. */
  6077. export interface CameraInputsMap<TCamera extends Camera> {
  6078. /**
  6079. * Accessor to the input by input type.
  6080. */
  6081. [name: string]: ICameraInput<TCamera>;
  6082. /**
  6083. * Accessor to the input by input index.
  6084. */
  6085. [idx: number]: ICameraInput<TCamera>;
  6086. }
  6087. /**
  6088. * This represents the input manager used within a camera.
  6089. * It helps dealing with all the different kind of input attached to a camera.
  6090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6091. */
  6092. export class CameraInputsManager<TCamera extends Camera> {
  6093. /**
  6094. * Defines the list of inputs attahed to the camera.
  6095. */
  6096. attached: CameraInputsMap<TCamera>;
  6097. /**
  6098. * Defines the dom element the camera is collecting inputs from.
  6099. * This is null if the controls have not been attached.
  6100. */
  6101. attachedElement: Nullable<HTMLElement>;
  6102. /**
  6103. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6104. */
  6105. noPreventDefault: boolean;
  6106. /**
  6107. * Defined the camera the input manager belongs to.
  6108. */
  6109. camera: TCamera;
  6110. /**
  6111. * Update the current camera state depending on the inputs that have been used this frame.
  6112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6113. */
  6114. checkInputs: () => void;
  6115. /**
  6116. * Instantiate a new Camera Input Manager.
  6117. * @param camera Defines the camera the input manager blongs to
  6118. */
  6119. constructor(camera: TCamera);
  6120. /**
  6121. * Add an input method to a camera
  6122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6123. * @param input camera input method
  6124. */
  6125. add(input: ICameraInput<TCamera>): void;
  6126. /**
  6127. * Remove a specific input method from a camera
  6128. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6129. * @param inputToRemove camera input method
  6130. */
  6131. remove(inputToRemove: ICameraInput<TCamera>): void;
  6132. /**
  6133. * Remove a specific input type from a camera
  6134. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6135. * @param inputType the type of the input to remove
  6136. */
  6137. removeByType(inputType: string): void;
  6138. private _addCheckInputs;
  6139. /**
  6140. * Attach the input controls to the currently attached dom element to listen the events from.
  6141. * @param input Defines the input to attach
  6142. */
  6143. attachInput(input: ICameraInput<TCamera>): void;
  6144. /**
  6145. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6146. * @param element Defines the dom element to collect the events from
  6147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6148. */
  6149. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6150. /**
  6151. * Detach the current manager inputs controls from a specific dom element.
  6152. * @param element Defines the dom element to collect the events from
  6153. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6154. */
  6155. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6156. /**
  6157. * Rebuild the dynamic inputCheck function from the current list of
  6158. * defined inputs in the manager.
  6159. */
  6160. rebuildInputCheck(): void;
  6161. /**
  6162. * Remove all attached input methods from a camera
  6163. */
  6164. clear(): void;
  6165. /**
  6166. * Serialize the current input manager attached to a camera.
  6167. * This ensures than once parsed,
  6168. * the input associated to the camera will be identical to the current ones
  6169. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6170. */
  6171. serialize(serializedCamera: any): void;
  6172. /**
  6173. * Parses an input manager serialized JSON to restore the previous list of inputs
  6174. * and states associated to a camera.
  6175. * @param parsedCamera Defines the JSON to parse
  6176. */
  6177. parse(parsedCamera: any): void;
  6178. }
  6179. }
  6180. declare module BABYLON {
  6181. /**
  6182. * Class used to store data that will be store in GPU memory
  6183. */
  6184. export class Buffer {
  6185. private _engine;
  6186. private _buffer;
  6187. /** @hidden */
  6188. _data: Nullable<DataArray>;
  6189. private _updatable;
  6190. private _instanced;
  6191. /**
  6192. * Gets the byte stride.
  6193. */
  6194. readonly byteStride: number;
  6195. /**
  6196. * Constructor
  6197. * @param engine the engine
  6198. * @param data the data to use for this buffer
  6199. * @param updatable whether the data is updatable
  6200. * @param stride the stride (optional)
  6201. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6202. * @param instanced whether the buffer is instanced (optional)
  6203. * @param useBytes set to true if the stride in in bytes (optional)
  6204. */
  6205. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6206. /**
  6207. * Create a new VertexBuffer based on the current buffer
  6208. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6209. * @param offset defines offset in the buffer (0 by default)
  6210. * @param size defines the size in floats of attributes (position is 3 for instance)
  6211. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6212. * @param instanced defines if the vertex buffer contains indexed data
  6213. * @param useBytes defines if the offset and stride are in bytes
  6214. * @returns the new vertex buffer
  6215. */
  6216. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6217. /**
  6218. * Gets a boolean indicating if the Buffer is updatable?
  6219. * @returns true if the buffer is updatable
  6220. */
  6221. isUpdatable(): boolean;
  6222. /**
  6223. * Gets current buffer's data
  6224. * @returns a DataArray or null
  6225. */
  6226. getData(): Nullable<DataArray>;
  6227. /**
  6228. * Gets underlying native buffer
  6229. * @returns underlying native buffer
  6230. */
  6231. getBuffer(): Nullable<DataBuffer>;
  6232. /**
  6233. * Gets the stride in float32 units (i.e. byte stride / 4).
  6234. * May not be an integer if the byte stride is not divisible by 4.
  6235. * DEPRECATED. Use byteStride instead.
  6236. * @returns the stride in float32 units
  6237. */
  6238. getStrideSize(): number;
  6239. /**
  6240. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6241. * @param data defines the data to store
  6242. */
  6243. create(data?: Nullable<DataArray>): void;
  6244. /** @hidden */
  6245. _rebuild(): void;
  6246. /**
  6247. * Update current buffer data
  6248. * @param data defines the data to store
  6249. */
  6250. update(data: DataArray): void;
  6251. /**
  6252. * Updates the data directly.
  6253. * @param data the new data
  6254. * @param offset the new offset
  6255. * @param vertexCount the vertex count (optional)
  6256. * @param useBytes set to true if the offset is in bytes
  6257. */
  6258. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6259. /**
  6260. * Release all resources
  6261. */
  6262. dispose(): void;
  6263. }
  6264. /**
  6265. * Specialized buffer used to store vertex data
  6266. */
  6267. export class VertexBuffer {
  6268. /** @hidden */
  6269. _buffer: Buffer;
  6270. private _kind;
  6271. private _size;
  6272. private _ownsBuffer;
  6273. private _instanced;
  6274. private _instanceDivisor;
  6275. /**
  6276. * The byte type.
  6277. */
  6278. static readonly BYTE: number;
  6279. /**
  6280. * The unsigned byte type.
  6281. */
  6282. static readonly UNSIGNED_BYTE: number;
  6283. /**
  6284. * The short type.
  6285. */
  6286. static readonly SHORT: number;
  6287. /**
  6288. * The unsigned short type.
  6289. */
  6290. static readonly UNSIGNED_SHORT: number;
  6291. /**
  6292. * The integer type.
  6293. */
  6294. static readonly INT: number;
  6295. /**
  6296. * The unsigned integer type.
  6297. */
  6298. static readonly UNSIGNED_INT: number;
  6299. /**
  6300. * The float type.
  6301. */
  6302. static readonly FLOAT: number;
  6303. /**
  6304. * Gets or sets the instance divisor when in instanced mode
  6305. */
  6306. instanceDivisor: number;
  6307. /**
  6308. * Gets the byte stride.
  6309. */
  6310. readonly byteStride: number;
  6311. /**
  6312. * Gets the byte offset.
  6313. */
  6314. readonly byteOffset: number;
  6315. /**
  6316. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6317. */
  6318. readonly normalized: boolean;
  6319. /**
  6320. * Gets the data type of each component in the array.
  6321. */
  6322. readonly type: number;
  6323. /**
  6324. * Constructor
  6325. * @param engine the engine
  6326. * @param data the data to use for this vertex buffer
  6327. * @param kind the vertex buffer kind
  6328. * @param updatable whether the data is updatable
  6329. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6330. * @param stride the stride (optional)
  6331. * @param instanced whether the buffer is instanced (optional)
  6332. * @param offset the offset of the data (optional)
  6333. * @param size the number of components (optional)
  6334. * @param type the type of the component (optional)
  6335. * @param normalized whether the data contains normalized data (optional)
  6336. * @param useBytes set to true if stride and offset are in bytes (optional)
  6337. */
  6338. 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);
  6339. /** @hidden */
  6340. _rebuild(): void;
  6341. /**
  6342. * Returns the kind of the VertexBuffer (string)
  6343. * @returns a string
  6344. */
  6345. getKind(): string;
  6346. /**
  6347. * Gets a boolean indicating if the VertexBuffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * DEPRECATED. Use byteStride instead.
  6365. * @returns the stride in float32 units
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Returns the offset as a multiple of the type byte length.
  6370. * DEPRECATED. Use byteOffset instead.
  6371. * @returns the offset in bytes
  6372. */
  6373. getOffset(): number;
  6374. /**
  6375. * Returns the number of components per vertex attribute (integer)
  6376. * @returns the size in float
  6377. */
  6378. getSize(): number;
  6379. /**
  6380. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6381. * @returns true if this buffer is instanced
  6382. */
  6383. getIsInstanced(): boolean;
  6384. /**
  6385. * Returns the instancing divisor, zero for non-instanced (integer).
  6386. * @returns a number
  6387. */
  6388. getInstanceDivisor(): number;
  6389. /**
  6390. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6391. * @param data defines the data to store
  6392. */
  6393. create(data?: DataArray): void;
  6394. /**
  6395. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6396. * This function will create a new buffer if the current one is not updatable
  6397. * @param data defines the data to store
  6398. */
  6399. update(data: DataArray): void;
  6400. /**
  6401. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6402. * Returns the directly updated WebGLBuffer.
  6403. * @param data the new data
  6404. * @param offset the new offset
  6405. * @param useBytes set to true if the offset is in bytes
  6406. */
  6407. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6408. /**
  6409. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6410. */
  6411. dispose(): void;
  6412. /**
  6413. * Enumerates each value of this vertex buffer as numbers.
  6414. * @param count the number of values to enumerate
  6415. * @param callback the callback function called for each value
  6416. */
  6417. forEach(count: number, callback: (value: number, index: number) => void): void;
  6418. /**
  6419. * Positions
  6420. */
  6421. static readonly PositionKind: string;
  6422. /**
  6423. * Normals
  6424. */
  6425. static readonly NormalKind: string;
  6426. /**
  6427. * Tangents
  6428. */
  6429. static readonly TangentKind: string;
  6430. /**
  6431. * Texture coordinates
  6432. */
  6433. static readonly UVKind: string;
  6434. /**
  6435. * Texture coordinates 2
  6436. */
  6437. static readonly UV2Kind: string;
  6438. /**
  6439. * Texture coordinates 3
  6440. */
  6441. static readonly UV3Kind: string;
  6442. /**
  6443. * Texture coordinates 4
  6444. */
  6445. static readonly UV4Kind: string;
  6446. /**
  6447. * Texture coordinates 5
  6448. */
  6449. static readonly UV5Kind: string;
  6450. /**
  6451. * Texture coordinates 6
  6452. */
  6453. static readonly UV6Kind: string;
  6454. /**
  6455. * Colors
  6456. */
  6457. static readonly ColorKind: string;
  6458. /**
  6459. * Matrix indices (for bones)
  6460. */
  6461. static readonly MatricesIndicesKind: string;
  6462. /**
  6463. * Matrix weights (for bones)
  6464. */
  6465. static readonly MatricesWeightsKind: string;
  6466. /**
  6467. * Additional matrix indices (for bones)
  6468. */
  6469. static readonly MatricesIndicesExtraKind: string;
  6470. /**
  6471. * Additional matrix weights (for bones)
  6472. */
  6473. static readonly MatricesWeightsExtraKind: string;
  6474. /**
  6475. * Deduces the stride given a kind.
  6476. * @param kind The kind string to deduce
  6477. * @returns The deduced stride
  6478. */
  6479. static DeduceStride(kind: string): number;
  6480. /**
  6481. * Gets the byte length of the given type.
  6482. * @param type the type
  6483. * @returns the number of bytes
  6484. */
  6485. static GetTypeByteLength(type: number): number;
  6486. /**
  6487. * Enumerates each value of the given parameters as numbers.
  6488. * @param data the data to enumerate
  6489. * @param byteOffset the byte offset of the data
  6490. * @param byteStride the byte stride of the data
  6491. * @param componentCount the number of components per element
  6492. * @param componentType the type of the component
  6493. * @param count the number of values to enumerate
  6494. * @param normalized whether the data is normalized
  6495. * @param callback the callback function called for each value
  6496. */
  6497. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6498. private static _GetFloatValue;
  6499. }
  6500. }
  6501. declare module BABYLON {
  6502. /**
  6503. * @hidden
  6504. */
  6505. export class IntersectionInfo {
  6506. bu: Nullable<number>;
  6507. bv: Nullable<number>;
  6508. distance: number;
  6509. faceId: number;
  6510. subMeshId: number;
  6511. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6512. }
  6513. }
  6514. declare module BABYLON {
  6515. /**
  6516. * Represens a plane by the equation ax + by + cz + d = 0
  6517. */
  6518. export class Plane {
  6519. private static _TmpMatrix;
  6520. /**
  6521. * Normal of the plane (a,b,c)
  6522. */
  6523. normal: Vector3;
  6524. /**
  6525. * d component of the plane
  6526. */
  6527. d: number;
  6528. /**
  6529. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6530. * @param a a component of the plane
  6531. * @param b b component of the plane
  6532. * @param c c component of the plane
  6533. * @param d d component of the plane
  6534. */
  6535. constructor(a: number, b: number, c: number, d: number);
  6536. /**
  6537. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6538. */
  6539. asArray(): number[];
  6540. /**
  6541. * @returns a new plane copied from the current Plane.
  6542. */
  6543. clone(): Plane;
  6544. /**
  6545. * @returns the string "Plane".
  6546. */
  6547. getClassName(): string;
  6548. /**
  6549. * @returns the Plane hash code.
  6550. */
  6551. getHashCode(): number;
  6552. /**
  6553. * Normalize the current Plane in place.
  6554. * @returns the updated Plane.
  6555. */
  6556. normalize(): Plane;
  6557. /**
  6558. * Applies a transformation the plane and returns the result
  6559. * @param transformation the transformation matrix to be applied to the plane
  6560. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6561. */
  6562. transform(transformation: DeepImmutable<Matrix>): Plane;
  6563. /**
  6564. * Calcualtte the dot product between the point and the plane normal
  6565. * @param point point to calculate the dot product with
  6566. * @returns the dot product (float) of the point coordinates and the plane normal.
  6567. */
  6568. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6569. /**
  6570. * Updates the current Plane from the plane defined by the three given points.
  6571. * @param point1 one of the points used to contruct the plane
  6572. * @param point2 one of the points used to contruct the plane
  6573. * @param point3 one of the points used to contruct the plane
  6574. * @returns the updated Plane.
  6575. */
  6576. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Checks if the plane is facing a given direction
  6579. * @param direction the direction to check if the plane is facing
  6580. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6581. * @returns True is the vector "direction" is the same side than the plane normal.
  6582. */
  6583. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6584. /**
  6585. * Calculates the distance to a point
  6586. * @param point point to calculate distance to
  6587. * @returns the signed distance (float) from the given point to the Plane.
  6588. */
  6589. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6590. /**
  6591. * Creates a plane from an array
  6592. * @param array the array to create a plane from
  6593. * @returns a new Plane from the given array.
  6594. */
  6595. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6596. /**
  6597. * Creates a plane from three points
  6598. * @param point1 point used to create the plane
  6599. * @param point2 point used to create the plane
  6600. * @param point3 point used to create the plane
  6601. * @returns a new Plane defined by the three given points.
  6602. */
  6603. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6604. /**
  6605. * Creates a plane from an origin point and a normal
  6606. * @param origin origin of the plane to be constructed
  6607. * @param normal normal of the plane to be constructed
  6608. * @returns a new Plane the normal vector to this plane at the given origin point.
  6609. * Note : the vector "normal" is updated because normalized.
  6610. */
  6611. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6612. /**
  6613. * Calculates the distance from a plane and a point
  6614. * @param origin origin of the plane to be constructed
  6615. * @param normal normal of the plane to be constructed
  6616. * @param point point to calculate distance to
  6617. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6618. */
  6619. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6620. }
  6621. }
  6622. declare module BABYLON {
  6623. /**
  6624. * Class used to store bounding sphere information
  6625. */
  6626. export class BoundingSphere {
  6627. /**
  6628. * Gets the center of the bounding sphere in local space
  6629. */
  6630. readonly center: Vector3;
  6631. /**
  6632. * Radius of the bounding sphere in local space
  6633. */
  6634. radius: number;
  6635. /**
  6636. * Gets the center of the bounding sphere in world space
  6637. */
  6638. readonly centerWorld: Vector3;
  6639. /**
  6640. * Radius of the bounding sphere in world space
  6641. */
  6642. radiusWorld: number;
  6643. /**
  6644. * Gets the minimum vector in local space
  6645. */
  6646. readonly minimum: Vector3;
  6647. /**
  6648. * Gets the maximum vector in local space
  6649. */
  6650. readonly maximum: Vector3;
  6651. private _worldMatrix;
  6652. private static readonly TmpVector3;
  6653. /**
  6654. * Creates a new bounding sphere
  6655. * @param min defines the minimum vector (in local space)
  6656. * @param max defines the maximum vector (in local space)
  6657. * @param worldMatrix defines the new world matrix
  6658. */
  6659. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6660. /**
  6661. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6662. * @param min defines the new minimum vector (in local space)
  6663. * @param max defines the new maximum vector (in local space)
  6664. * @param worldMatrix defines the new world matrix
  6665. */
  6666. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6667. /**
  6668. * Scale the current bounding sphere by applying a scale factor
  6669. * @param factor defines the scale factor to apply
  6670. * @returns the current bounding box
  6671. */
  6672. scale(factor: number): BoundingSphere;
  6673. /**
  6674. * Gets the world matrix of the bounding box
  6675. * @returns a matrix
  6676. */
  6677. getWorldMatrix(): DeepImmutable<Matrix>;
  6678. /** @hidden */
  6679. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6680. /**
  6681. * Tests if the bounding sphere is intersecting the frustum planes
  6682. * @param frustumPlanes defines the frustum planes to test
  6683. * @returns true if there is an intersection
  6684. */
  6685. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6686. /**
  6687. * Tests if the bounding sphere center is in between the frustum planes.
  6688. * Used for optimistic fast inclusion.
  6689. * @param frustumPlanes defines the frustum planes to test
  6690. * @returns true if the sphere center is in between the frustum planes
  6691. */
  6692. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6693. /**
  6694. * Tests if a point is inside the bounding sphere
  6695. * @param point defines the point to test
  6696. * @returns true if the point is inside the bounding sphere
  6697. */
  6698. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6699. /**
  6700. * Checks if two sphere intersct
  6701. * @param sphere0 sphere 0
  6702. * @param sphere1 sphere 1
  6703. * @returns true if the speres intersect
  6704. */
  6705. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6706. }
  6707. }
  6708. declare module BABYLON {
  6709. /**
  6710. * Class used to store bounding box information
  6711. */
  6712. export class BoundingBox implements ICullable {
  6713. /**
  6714. * Gets the 8 vectors representing the bounding box in local space
  6715. */
  6716. readonly vectors: Vector3[];
  6717. /**
  6718. * Gets the center of the bounding box in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Gets the center of the bounding box in world space
  6723. */
  6724. readonly centerWorld: Vector3;
  6725. /**
  6726. * Gets the extend size in local space
  6727. */
  6728. readonly extendSize: Vector3;
  6729. /**
  6730. * Gets the extend size in world space
  6731. */
  6732. readonly extendSizeWorld: Vector3;
  6733. /**
  6734. * Gets the OBB (object bounding box) directions
  6735. */
  6736. readonly directions: Vector3[];
  6737. /**
  6738. * Gets the 8 vectors representing the bounding box in world space
  6739. */
  6740. readonly vectorsWorld: Vector3[];
  6741. /**
  6742. * Gets the minimum vector in world space
  6743. */
  6744. readonly minimumWorld: Vector3;
  6745. /**
  6746. * Gets the maximum vector in world space
  6747. */
  6748. readonly maximumWorld: Vector3;
  6749. /**
  6750. * Gets the minimum vector in local space
  6751. */
  6752. readonly minimum: Vector3;
  6753. /**
  6754. * Gets the maximum vector in local space
  6755. */
  6756. readonly maximum: Vector3;
  6757. private _worldMatrix;
  6758. private static readonly TmpVector3;
  6759. /**
  6760. * @hidden
  6761. */
  6762. _tag: number;
  6763. /**
  6764. * Creates a new bounding box
  6765. * @param min defines the minimum vector (in local space)
  6766. * @param max defines the maximum vector (in local space)
  6767. * @param worldMatrix defines the new world matrix
  6768. */
  6769. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6770. /**
  6771. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6772. * @param min defines the new minimum vector (in local space)
  6773. * @param max defines the new maximum vector (in local space)
  6774. * @param worldMatrix defines the new world matrix
  6775. */
  6776. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6777. /**
  6778. * Scale the current bounding box by applying a scale factor
  6779. * @param factor defines the scale factor to apply
  6780. * @returns the current bounding box
  6781. */
  6782. scale(factor: number): BoundingBox;
  6783. /**
  6784. * Gets the world matrix of the bounding box
  6785. * @returns a matrix
  6786. */
  6787. getWorldMatrix(): DeepImmutable<Matrix>;
  6788. /** @hidden */
  6789. _update(world: DeepImmutable<Matrix>): void;
  6790. /**
  6791. * Tests if the bounding box is intersecting the frustum planes
  6792. * @param frustumPlanes defines the frustum planes to test
  6793. * @returns true if there is an intersection
  6794. */
  6795. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6796. /**
  6797. * Tests if the bounding box is entirely inside the frustum planes
  6798. * @param frustumPlanes defines the frustum planes to test
  6799. * @returns true if there is an inclusion
  6800. */
  6801. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6802. /**
  6803. * Tests if a point is inside the bounding box
  6804. * @param point defines the point to test
  6805. * @returns true if the point is inside the bounding box
  6806. */
  6807. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6808. /**
  6809. * Tests if the bounding box intersects with a bounding sphere
  6810. * @param sphere defines the sphere to test
  6811. * @returns true if there is an intersection
  6812. */
  6813. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6814. /**
  6815. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6816. * @param min defines the min vector to use
  6817. * @param max defines the max vector to use
  6818. * @returns true if there is an intersection
  6819. */
  6820. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6821. /**
  6822. * Tests if two bounding boxes are intersections
  6823. * @param box0 defines the first box to test
  6824. * @param box1 defines the second box to test
  6825. * @returns true if there is an intersection
  6826. */
  6827. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6828. /**
  6829. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6830. * @param minPoint defines the minimum vector of the bounding box
  6831. * @param maxPoint defines the maximum vector of the bounding box
  6832. * @param sphereCenter defines the sphere center
  6833. * @param sphereRadius defines the sphere radius
  6834. * @returns true if there is an intersection
  6835. */
  6836. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6837. /**
  6838. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6839. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6840. * @param frustumPlanes defines the frustum planes to test
  6841. * @return true if there is an inclusion
  6842. */
  6843. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6844. /**
  6845. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6846. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6847. * @param frustumPlanes defines the frustum planes to test
  6848. * @return true if there is an intersection
  6849. */
  6850. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6851. }
  6852. }
  6853. declare module BABYLON {
  6854. /** @hidden */
  6855. export class Collider {
  6856. /** Define if a collision was found */
  6857. collisionFound: boolean;
  6858. /**
  6859. * Define last intersection point in local space
  6860. */
  6861. intersectionPoint: Vector3;
  6862. /**
  6863. * Define last collided mesh
  6864. */
  6865. collidedMesh: Nullable<AbstractMesh>;
  6866. private _collisionPoint;
  6867. private _planeIntersectionPoint;
  6868. private _tempVector;
  6869. private _tempVector2;
  6870. private _tempVector3;
  6871. private _tempVector4;
  6872. private _edge;
  6873. private _baseToVertex;
  6874. private _destinationPoint;
  6875. private _slidePlaneNormal;
  6876. private _displacementVector;
  6877. /** @hidden */
  6878. _radius: Vector3;
  6879. /** @hidden */
  6880. _retry: number;
  6881. private _velocity;
  6882. private _basePoint;
  6883. private _epsilon;
  6884. /** @hidden */
  6885. _velocityWorldLength: number;
  6886. /** @hidden */
  6887. _basePointWorld: Vector3;
  6888. private _velocityWorld;
  6889. private _normalizedVelocity;
  6890. /** @hidden */
  6891. _initialVelocity: Vector3;
  6892. /** @hidden */
  6893. _initialPosition: Vector3;
  6894. private _nearestDistance;
  6895. private _collisionMask;
  6896. collisionMask: number;
  6897. /**
  6898. * Gets the plane normal used to compute the sliding response (in local space)
  6899. */
  6900. readonly slidePlaneNormal: Vector3;
  6901. /** @hidden */
  6902. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6903. /** @hidden */
  6904. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6905. /** @hidden */
  6906. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6907. /** @hidden */
  6908. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6909. /** @hidden */
  6910. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6911. /** @hidden */
  6912. _getResponse(pos: Vector3, vel: Vector3): void;
  6913. }
  6914. }
  6915. declare module BABYLON {
  6916. /**
  6917. * Interface for cullable objects
  6918. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6919. */
  6920. export interface ICullable {
  6921. /**
  6922. * Checks if the object or part of the object is in the frustum
  6923. * @param frustumPlanes Camera near/planes
  6924. * @returns true if the object is in frustum otherwise false
  6925. */
  6926. isInFrustum(frustumPlanes: Plane[]): boolean;
  6927. /**
  6928. * Checks if a cullable object (mesh...) is in the camera frustum
  6929. * Unlike isInFrustum this cheks the full bounding box
  6930. * @param frustumPlanes Camera near/planes
  6931. * @returns true if the object is in frustum otherwise false
  6932. */
  6933. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6934. }
  6935. /**
  6936. * Info for a bounding data of a mesh
  6937. */
  6938. export class BoundingInfo implements ICullable {
  6939. /**
  6940. * Bounding box for the mesh
  6941. */
  6942. readonly boundingBox: BoundingBox;
  6943. /**
  6944. * Bounding sphere for the mesh
  6945. */
  6946. readonly boundingSphere: BoundingSphere;
  6947. private _isLocked;
  6948. private static readonly TmpVector3;
  6949. /**
  6950. * Constructs bounding info
  6951. * @param minimum min vector of the bounding box/sphere
  6952. * @param maximum max vector of the bounding box/sphere
  6953. * @param worldMatrix defines the new world matrix
  6954. */
  6955. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6956. /**
  6957. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6958. * @param min defines the new minimum vector (in local space)
  6959. * @param max defines the new maximum vector (in local space)
  6960. * @param worldMatrix defines the new world matrix
  6961. */
  6962. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6963. /**
  6964. * min vector of the bounding box/sphere
  6965. */
  6966. readonly minimum: Vector3;
  6967. /**
  6968. * max vector of the bounding box/sphere
  6969. */
  6970. readonly maximum: Vector3;
  6971. /**
  6972. * If the info is locked and won't be updated to avoid perf overhead
  6973. */
  6974. isLocked: boolean;
  6975. /**
  6976. * Updates the bounding sphere and box
  6977. * @param world world matrix to be used to update
  6978. */
  6979. update(world: DeepImmutable<Matrix>): void;
  6980. /**
  6981. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6982. * @param center New center of the bounding info
  6983. * @param extend New extend of the bounding info
  6984. * @returns the current bounding info
  6985. */
  6986. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6987. /**
  6988. * Scale the current bounding info by applying a scale factor
  6989. * @param factor defines the scale factor to apply
  6990. * @returns the current bounding info
  6991. */
  6992. scale(factor: number): BoundingInfo;
  6993. /**
  6994. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6995. * @param frustumPlanes defines the frustum to test
  6996. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6997. * @returns true if the bounding info is in the frustum planes
  6998. */
  6999. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7000. /**
  7001. * Gets the world distance between the min and max points of the bounding box
  7002. */
  7003. readonly diagonalLength: number;
  7004. /**
  7005. * Checks if a cullable object (mesh...) is in the camera frustum
  7006. * Unlike isInFrustum this cheks the full bounding box
  7007. * @param frustumPlanes Camera near/planes
  7008. * @returns true if the object is in frustum otherwise false
  7009. */
  7010. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7011. /** @hidden */
  7012. _checkCollision(collider: Collider): boolean;
  7013. /**
  7014. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7015. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7016. * @param point the point to check intersection with
  7017. * @returns if the point intersects
  7018. */
  7019. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7020. /**
  7021. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7022. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7023. * @param boundingInfo the bounding info to check intersection with
  7024. * @param precise if the intersection should be done using OBB
  7025. * @returns if the bounding info intersects
  7026. */
  7027. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7028. }
  7029. }
  7030. declare module BABYLON {
  7031. /**
  7032. * Extracts minimum and maximum values from a list of indexed positions
  7033. * @param positions defines the positions to use
  7034. * @param indices defines the indices to the positions
  7035. * @param indexStart defines the start index
  7036. * @param indexCount defines the end index
  7037. * @param bias defines bias value to add to the result
  7038. * @return minimum and maximum values
  7039. */
  7040. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7041. minimum: Vector3;
  7042. maximum: Vector3;
  7043. };
  7044. /**
  7045. * Extracts minimum and maximum values from a list of positions
  7046. * @param positions defines the positions to use
  7047. * @param start defines the start index in the positions array
  7048. * @param count defines the number of positions to handle
  7049. * @param bias defines bias value to add to the result
  7050. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7051. * @return minimum and maximum values
  7052. */
  7053. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7054. minimum: Vector3;
  7055. maximum: Vector3;
  7056. };
  7057. }
  7058. declare module BABYLON {
  7059. /** @hidden */
  7060. export class WebGLDataBuffer extends DataBuffer {
  7061. private _buffer;
  7062. constructor(resource: WebGLBuffer);
  7063. readonly underlyingResource: any;
  7064. }
  7065. }
  7066. declare module BABYLON {
  7067. /** @hidden */
  7068. export class WebGLPipelineContext implements IPipelineContext {
  7069. engine: ThinEngine;
  7070. program: Nullable<WebGLProgram>;
  7071. context?: WebGLRenderingContext;
  7072. vertexShader?: WebGLShader;
  7073. fragmentShader?: WebGLShader;
  7074. isParallelCompiled: boolean;
  7075. onCompiled?: () => void;
  7076. transformFeedback?: WebGLTransformFeedback | null;
  7077. readonly isAsync: boolean;
  7078. readonly isReady: boolean;
  7079. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7080. }
  7081. }
  7082. declare module BABYLON {
  7083. interface ThinEngine {
  7084. /**
  7085. * Create an uniform buffer
  7086. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7087. * @param elements defines the content of the uniform buffer
  7088. * @returns the webGL uniform buffer
  7089. */
  7090. createUniformBuffer(elements: FloatArray): DataBuffer;
  7091. /**
  7092. * Create a dynamic uniform buffer
  7093. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7094. * @param elements defines the content of the uniform buffer
  7095. * @returns the webGL uniform buffer
  7096. */
  7097. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7098. /**
  7099. * Update an existing uniform buffer
  7100. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7101. * @param uniformBuffer defines the target uniform buffer
  7102. * @param elements defines the content to update
  7103. * @param offset defines the offset in the uniform buffer where update should start
  7104. * @param count defines the size of the data to update
  7105. */
  7106. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7107. /**
  7108. * Bind an uniform buffer to the current webGL context
  7109. * @param buffer defines the buffer to bind
  7110. */
  7111. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7112. /**
  7113. * Bind a buffer to the current webGL context at a given location
  7114. * @param buffer defines the buffer to bind
  7115. * @param location defines the index where to bind the buffer
  7116. */
  7117. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7118. /**
  7119. * Bind a specific block at a given index in a specific shader program
  7120. * @param pipelineContext defines the pipeline context to use
  7121. * @param blockName defines the block name
  7122. * @param index defines the index where to bind the block
  7123. */
  7124. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7125. }
  7126. }
  7127. declare module BABYLON {
  7128. /**
  7129. * Uniform buffer objects.
  7130. *
  7131. * Handles blocks of uniform on the GPU.
  7132. *
  7133. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7134. *
  7135. * For more information, please refer to :
  7136. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7137. */
  7138. export class UniformBuffer {
  7139. private _engine;
  7140. private _buffer;
  7141. private _data;
  7142. private _bufferData;
  7143. private _dynamic?;
  7144. private _uniformLocations;
  7145. private _uniformSizes;
  7146. private _uniformLocationPointer;
  7147. private _needSync;
  7148. private _noUBO;
  7149. private _currentEffect;
  7150. private static _MAX_UNIFORM_SIZE;
  7151. private static _tempBuffer;
  7152. /**
  7153. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7154. * This is dynamic to allow compat with webgl 1 and 2.
  7155. * You will need to pass the name of the uniform as well as the value.
  7156. */
  7157. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7158. /**
  7159. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7160. * This is dynamic to allow compat with webgl 1 and 2.
  7161. * You will need to pass the name of the uniform as well as the value.
  7162. */
  7163. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7164. /**
  7165. * Lambda to Update a single float in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateFloat: (name: string, x: number) => void;
  7170. /**
  7171. * Lambda to Update a vec2 of float in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7176. /**
  7177. * Lambda to Update a vec3 of float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7182. /**
  7183. * Lambda to Update a vec4 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateMatrix: (name: string, mat: Matrix) => void;
  7194. /**
  7195. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateVector3: (name: string, vector: Vector3) => void;
  7200. /**
  7201. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateVector4: (name: string, vector: Vector4) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7218. /**
  7219. * Instantiates a new Uniform buffer objects.
  7220. *
  7221. * Handles blocks of uniform on the GPU.
  7222. *
  7223. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7224. *
  7225. * For more information, please refer to :
  7226. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7227. * @param engine Define the engine the buffer is associated with
  7228. * @param data Define the data contained in the buffer
  7229. * @param dynamic Define if the buffer is updatable
  7230. */
  7231. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7232. /**
  7233. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7234. * or just falling back on setUniformXXX calls.
  7235. */
  7236. readonly useUbo: boolean;
  7237. /**
  7238. * Indicates if the WebGL underlying uniform buffer is in sync
  7239. * with the javascript cache data.
  7240. */
  7241. readonly isSync: boolean;
  7242. /**
  7243. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7244. * Also, a dynamic UniformBuffer will disable cache verification and always
  7245. * update the underlying WebGL uniform buffer to the GPU.
  7246. * @returns if Dynamic, otherwise false
  7247. */
  7248. isDynamic(): boolean;
  7249. /**
  7250. * The data cache on JS side.
  7251. * @returns the underlying data as a float array
  7252. */
  7253. getData(): Float32Array;
  7254. /**
  7255. * The underlying WebGL Uniform buffer.
  7256. * @returns the webgl buffer
  7257. */
  7258. getBuffer(): Nullable<DataBuffer>;
  7259. /**
  7260. * std140 layout specifies how to align data within an UBO structure.
  7261. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7262. * for specs.
  7263. */
  7264. private _fillAlignment;
  7265. /**
  7266. * Adds an uniform in the buffer.
  7267. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7268. * for the layout to be correct !
  7269. * @param name Name of the uniform, as used in the uniform block in the shader.
  7270. * @param size Data size, or data directly.
  7271. */
  7272. addUniform(name: string, size: number | number[]): void;
  7273. /**
  7274. * Adds a Matrix 4x4 to the uniform buffer.
  7275. * @param name Name of the uniform, as used in the uniform block in the shader.
  7276. * @param mat A 4x4 matrix.
  7277. */
  7278. addMatrix(name: string, mat: Matrix): void;
  7279. /**
  7280. * Adds a vec2 to the uniform buffer.
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param x Define the x component value of the vec2
  7283. * @param y Define the y component value of the vec2
  7284. */
  7285. addFloat2(name: string, x: number, y: number): void;
  7286. /**
  7287. * Adds a vec3 to the uniform buffer.
  7288. * @param name Name of the uniform, as used in the uniform block in the shader.
  7289. * @param x Define the x component value of the vec3
  7290. * @param y Define the y component value of the vec3
  7291. * @param z Define the z component value of the vec3
  7292. */
  7293. addFloat3(name: string, x: number, y: number, z: number): void;
  7294. /**
  7295. * Adds a vec3 to the uniform buffer.
  7296. * @param name Name of the uniform, as used in the uniform block in the shader.
  7297. * @param color Define the vec3 from a Color
  7298. */
  7299. addColor3(name: string, color: Color3): void;
  7300. /**
  7301. * Adds a vec4 to the uniform buffer.
  7302. * @param name Name of the uniform, as used in the uniform block in the shader.
  7303. * @param color Define the rgb components from a Color
  7304. * @param alpha Define the a component of the vec4
  7305. */
  7306. addColor4(name: string, color: Color3, alpha: number): void;
  7307. /**
  7308. * Adds a vec3 to the uniform buffer.
  7309. * @param name Name of the uniform, as used in the uniform block in the shader.
  7310. * @param vector Define the vec3 components from a Vector
  7311. */
  7312. addVector3(name: string, vector: Vector3): void;
  7313. /**
  7314. * Adds a Matrix 3x3 to the uniform buffer.
  7315. * @param name Name of the uniform, as used in the uniform block in the shader.
  7316. */
  7317. addMatrix3x3(name: string): void;
  7318. /**
  7319. * Adds a Matrix 2x2 to the uniform buffer.
  7320. * @param name Name of the uniform, as used in the uniform block in the shader.
  7321. */
  7322. addMatrix2x2(name: string): void;
  7323. /**
  7324. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7325. */
  7326. create(): void;
  7327. /** @hidden */
  7328. _rebuild(): void;
  7329. /**
  7330. * Updates the WebGL Uniform Buffer on the GPU.
  7331. * If the `dynamic` flag is set to true, no cache comparison is done.
  7332. * Otherwise, the buffer will be updated only if the cache differs.
  7333. */
  7334. update(): void;
  7335. /**
  7336. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7337. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7338. * @param data Define the flattened data
  7339. * @param size Define the size of the data.
  7340. */
  7341. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7342. private _valueCache;
  7343. private _cacheMatrix;
  7344. private _updateMatrix3x3ForUniform;
  7345. private _updateMatrix3x3ForEffect;
  7346. private _updateMatrix2x2ForEffect;
  7347. private _updateMatrix2x2ForUniform;
  7348. private _updateFloatForEffect;
  7349. private _updateFloatForUniform;
  7350. private _updateFloat2ForEffect;
  7351. private _updateFloat2ForUniform;
  7352. private _updateFloat3ForEffect;
  7353. private _updateFloat3ForUniform;
  7354. private _updateFloat4ForEffect;
  7355. private _updateFloat4ForUniform;
  7356. private _updateMatrixForEffect;
  7357. private _updateMatrixForUniform;
  7358. private _updateVector3ForEffect;
  7359. private _updateVector3ForUniform;
  7360. private _updateVector4ForEffect;
  7361. private _updateVector4ForUniform;
  7362. private _updateColor3ForEffect;
  7363. private _updateColor3ForUniform;
  7364. private _updateColor4ForEffect;
  7365. private _updateColor4ForUniform;
  7366. /**
  7367. * Sets a sampler uniform on the effect.
  7368. * @param name Define the name of the sampler.
  7369. * @param texture Define the texture to set in the sampler
  7370. */
  7371. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7372. /**
  7373. * Directly updates the value of the uniform in the cache AND on the GPU.
  7374. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7375. * @param data Define the flattened data
  7376. */
  7377. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7378. /**
  7379. * Binds this uniform buffer to an effect.
  7380. * @param effect Define the effect to bind the buffer to
  7381. * @param name Name of the uniform block in the shader.
  7382. */
  7383. bindToEffect(effect: Effect, name: string): void;
  7384. /**
  7385. * Disposes the uniform buffer.
  7386. */
  7387. dispose(): void;
  7388. }
  7389. }
  7390. declare module BABYLON {
  7391. /**
  7392. * Enum that determines the text-wrapping mode to use.
  7393. */
  7394. export enum InspectableType {
  7395. /**
  7396. * Checkbox for booleans
  7397. */
  7398. Checkbox = 0,
  7399. /**
  7400. * Sliders for numbers
  7401. */
  7402. Slider = 1,
  7403. /**
  7404. * Vector3
  7405. */
  7406. Vector3 = 2,
  7407. /**
  7408. * Quaternions
  7409. */
  7410. Quaternion = 3,
  7411. /**
  7412. * Color3
  7413. */
  7414. Color3 = 4,
  7415. /**
  7416. * String
  7417. */
  7418. String = 5
  7419. }
  7420. /**
  7421. * Interface used to define custom inspectable properties.
  7422. * This interface is used by the inspector to display custom property grids
  7423. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7424. */
  7425. export interface IInspectable {
  7426. /**
  7427. * Gets the label to display
  7428. */
  7429. label: string;
  7430. /**
  7431. * Gets the name of the property to edit
  7432. */
  7433. propertyName: string;
  7434. /**
  7435. * Gets the type of the editor to use
  7436. */
  7437. type: InspectableType;
  7438. /**
  7439. * Gets the minimum value of the property when using in "slider" mode
  7440. */
  7441. min?: number;
  7442. /**
  7443. * Gets the maximum value of the property when using in "slider" mode
  7444. */
  7445. max?: number;
  7446. /**
  7447. * Gets the setp to use when using in "slider" mode
  7448. */
  7449. step?: number;
  7450. }
  7451. }
  7452. declare module BABYLON {
  7453. /**
  7454. * Class used to provide helper for timing
  7455. */
  7456. export class TimingTools {
  7457. /**
  7458. * Polyfill for setImmediate
  7459. * @param action defines the action to execute after the current execution block
  7460. */
  7461. static SetImmediate(action: () => void): void;
  7462. }
  7463. }
  7464. declare module BABYLON {
  7465. /**
  7466. * Class used to enable instatition of objects by class name
  7467. */
  7468. export class InstantiationTools {
  7469. /**
  7470. * Use this object to register external classes like custom textures or material
  7471. * to allow the laoders to instantiate them
  7472. */
  7473. static RegisteredExternalClasses: {
  7474. [key: string]: Object;
  7475. };
  7476. /**
  7477. * Tries to instantiate a new object from a given class name
  7478. * @param className defines the class name to instantiate
  7479. * @returns the new object or null if the system was not able to do the instantiation
  7480. */
  7481. static Instantiate(className: string): any;
  7482. }
  7483. }
  7484. declare module BABYLON {
  7485. /**
  7486. * Define options used to create a depth texture
  7487. */
  7488. export class DepthTextureCreationOptions {
  7489. /** Specifies whether or not a stencil should be allocated in the texture */
  7490. generateStencil?: boolean;
  7491. /** Specifies whether or not bilinear filtering is enable on the texture */
  7492. bilinearFiltering?: boolean;
  7493. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7494. comparisonFunction?: number;
  7495. /** Specifies if the created texture is a cube texture */
  7496. isCube?: boolean;
  7497. }
  7498. }
  7499. declare module BABYLON {
  7500. interface ThinEngine {
  7501. /**
  7502. * Creates a depth stencil cube texture.
  7503. * This is only available in WebGL 2.
  7504. * @param size The size of face edge in the cube texture.
  7505. * @param options The options defining the cube texture.
  7506. * @returns The cube texture
  7507. */
  7508. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7509. /**
  7510. * Creates a cube texture
  7511. * @param rootUrl defines the url where the files to load is located
  7512. * @param scene defines the current scene
  7513. * @param files defines the list of files to load (1 per face)
  7514. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7515. * @param onLoad defines an optional callback raised when the texture is loaded
  7516. * @param onError defines an optional callback raised if there is an issue to load the texture
  7517. * @param format defines the format of the data
  7518. * @param forcedExtension defines the extension to use to pick the right loader
  7519. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7520. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7521. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7522. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7523. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7524. * @returns the cube texture as an InternalTexture
  7525. */
  7526. 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;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @returns the cube texture as an InternalTexture
  7538. */
  7539. 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;
  7540. /**
  7541. * Creates a cube texture
  7542. * @param rootUrl defines the url where the files to load is located
  7543. * @param scene defines the current scene
  7544. * @param files defines the list of files to load (1 per face)
  7545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7546. * @param onLoad defines an optional callback raised when the texture is loaded
  7547. * @param onError defines an optional callback raised if there is an issue to load the texture
  7548. * @param format defines the format of the data
  7549. * @param forcedExtension defines the extension to use to pick the right loader
  7550. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7553. * @returns the cube texture as an InternalTexture
  7554. */
  7555. 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;
  7556. /** @hidden */
  7557. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7558. /** @hidden */
  7559. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7560. /** @hidden */
  7561. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7562. /** @hidden */
  7563. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7564. }
  7565. }
  7566. declare module BABYLON {
  7567. /**
  7568. * Class for creating a cube texture
  7569. */
  7570. export class CubeTexture extends BaseTexture {
  7571. private _delayedOnLoad;
  7572. /**
  7573. * The url of the texture
  7574. */
  7575. url: string;
  7576. /**
  7577. * Gets or sets the center of the bounding box associated with the cube texture.
  7578. * It must define where the camera used to render the texture was set
  7579. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7580. */
  7581. boundingBoxPosition: Vector3;
  7582. private _boundingBoxSize;
  7583. /**
  7584. * Gets or sets the size of the bounding box associated with the cube texture
  7585. * When defined, the cubemap will switch to local mode
  7586. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7587. * @example https://www.babylonjs-playground.com/#RNASML
  7588. */
  7589. /**
  7590. * Returns the bounding box size
  7591. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7592. */
  7593. boundingBoxSize: Vector3;
  7594. protected _rotationY: number;
  7595. /**
  7596. * Sets texture matrix rotation angle around Y axis in radians.
  7597. */
  7598. /**
  7599. * Gets texture matrix rotation angle around Y axis radians.
  7600. */
  7601. rotationY: number;
  7602. /**
  7603. * Are mip maps generated for this texture or not.
  7604. */
  7605. readonly noMipmap: boolean;
  7606. private _noMipmap;
  7607. private _files;
  7608. private _extensions;
  7609. private _textureMatrix;
  7610. private _format;
  7611. private _createPolynomials;
  7612. /** @hidden */
  7613. _prefiltered: boolean;
  7614. /**
  7615. * Creates a cube texture from an array of image urls
  7616. * @param files defines an array of image urls
  7617. * @param scene defines the hosting scene
  7618. * @param noMipmap specifies if mip maps are not used
  7619. * @returns a cube texture
  7620. */
  7621. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7622. /**
  7623. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7624. * @param url defines the url of the prefiltered texture
  7625. * @param scene defines the scene the texture is attached to
  7626. * @param forcedExtension defines the extension of the file if different from the url
  7627. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7628. * @return the prefiltered texture
  7629. */
  7630. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7631. /**
  7632. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7633. * as prefiltered data.
  7634. * @param rootUrl defines the url of the texture or the root name of the six images
  7635. * @param scene defines the scene the texture is attached to
  7636. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7637. * @param noMipmap defines if mipmaps should be created or not
  7638. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7639. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7640. * @param onError defines a callback triggered in case of error during load
  7641. * @param format defines the internal format to use for the texture once loaded
  7642. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7643. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7644. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7645. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7646. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7647. * @return the cube texture
  7648. */
  7649. 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);
  7650. /**
  7651. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7652. */
  7653. readonly isPrefiltered: boolean;
  7654. /**
  7655. * Get the current class name of the texture useful for serialization or dynamic coding.
  7656. * @returns "CubeTexture"
  7657. */
  7658. getClassName(): string;
  7659. /**
  7660. * Update the url (and optional buffer) of this texture if url was null during construction.
  7661. * @param url the url of the texture
  7662. * @param forcedExtension defines the extension to use
  7663. * @param onLoad callback called when the texture is loaded (defaults to null)
  7664. */
  7665. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7666. /**
  7667. * Delays loading of the cube texture
  7668. * @param forcedExtension defines the extension to use
  7669. */
  7670. delayLoad(forcedExtension?: string): void;
  7671. /**
  7672. * Returns the reflection texture matrix
  7673. * @returns the reflection texture matrix
  7674. */
  7675. getReflectionTextureMatrix(): Matrix;
  7676. /**
  7677. * Sets the reflection texture matrix
  7678. * @param value Reflection texture matrix
  7679. */
  7680. setReflectionTextureMatrix(value: Matrix): void;
  7681. /**
  7682. * Parses text to create a cube texture
  7683. * @param parsedTexture define the serialized text to read from
  7684. * @param scene defines the hosting scene
  7685. * @param rootUrl defines the root url of the cube texture
  7686. * @returns a cube texture
  7687. */
  7688. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7689. /**
  7690. * Makes a clone, or deep copy, of the cube texture
  7691. * @returns a new cube texture
  7692. */
  7693. clone(): CubeTexture;
  7694. }
  7695. }
  7696. declare module BABYLON {
  7697. /**
  7698. * Manages the defines for the Material
  7699. */
  7700. export class MaterialDefines {
  7701. /** @hidden */
  7702. protected _keys: string[];
  7703. private _isDirty;
  7704. /** @hidden */
  7705. _renderId: number;
  7706. /** @hidden */
  7707. _areLightsDirty: boolean;
  7708. /** @hidden */
  7709. _areLightsDisposed: boolean;
  7710. /** @hidden */
  7711. _areAttributesDirty: boolean;
  7712. /** @hidden */
  7713. _areTexturesDirty: boolean;
  7714. /** @hidden */
  7715. _areFresnelDirty: boolean;
  7716. /** @hidden */
  7717. _areMiscDirty: boolean;
  7718. /** @hidden */
  7719. _areImageProcessingDirty: boolean;
  7720. /** @hidden */
  7721. _normals: boolean;
  7722. /** @hidden */
  7723. _uvs: boolean;
  7724. /** @hidden */
  7725. _needNormals: boolean;
  7726. /** @hidden */
  7727. _needUVs: boolean;
  7728. [id: string]: any;
  7729. /**
  7730. * Specifies if the material needs to be re-calculated
  7731. */
  7732. readonly isDirty: boolean;
  7733. /**
  7734. * Marks the material to indicate that it has been re-calculated
  7735. */
  7736. markAsProcessed(): void;
  7737. /**
  7738. * Marks the material to indicate that it needs to be re-calculated
  7739. */
  7740. markAsUnprocessed(): void;
  7741. /**
  7742. * Marks the material to indicate all of its defines need to be re-calculated
  7743. */
  7744. markAllAsDirty(): void;
  7745. /**
  7746. * Marks the material to indicate that image processing needs to be re-calculated
  7747. */
  7748. markAsImageProcessingDirty(): void;
  7749. /**
  7750. * Marks the material to indicate the lights need to be re-calculated
  7751. * @param disposed Defines whether the light is dirty due to dispose or not
  7752. */
  7753. markAsLightDirty(disposed?: boolean): void;
  7754. /**
  7755. * Marks the attribute state as changed
  7756. */
  7757. markAsAttributesDirty(): void;
  7758. /**
  7759. * Marks the texture state as changed
  7760. */
  7761. markAsTexturesDirty(): void;
  7762. /**
  7763. * Marks the fresnel state as changed
  7764. */
  7765. markAsFresnelDirty(): void;
  7766. /**
  7767. * Marks the misc state as changed
  7768. */
  7769. markAsMiscDirty(): void;
  7770. /**
  7771. * Rebuilds the material defines
  7772. */
  7773. rebuild(): void;
  7774. /**
  7775. * Specifies if two material defines are equal
  7776. * @param other - A material define instance to compare to
  7777. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7778. */
  7779. isEqual(other: MaterialDefines): boolean;
  7780. /**
  7781. * Clones this instance's defines to another instance
  7782. * @param other - material defines to clone values to
  7783. */
  7784. cloneTo(other: MaterialDefines): void;
  7785. /**
  7786. * Resets the material define values
  7787. */
  7788. reset(): void;
  7789. /**
  7790. * Converts the material define values to a string
  7791. * @returns - String of material define information
  7792. */
  7793. toString(): string;
  7794. }
  7795. }
  7796. declare module BABYLON {
  7797. /**
  7798. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7799. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7800. * 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;
  7801. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7802. */
  7803. export class ColorCurves {
  7804. private _dirty;
  7805. private _tempColor;
  7806. private _globalCurve;
  7807. private _highlightsCurve;
  7808. private _midtonesCurve;
  7809. private _shadowsCurve;
  7810. private _positiveCurve;
  7811. private _negativeCurve;
  7812. private _globalHue;
  7813. private _globalDensity;
  7814. private _globalSaturation;
  7815. private _globalExposure;
  7816. /**
  7817. * Gets the global Hue value.
  7818. * 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).
  7819. */
  7820. /**
  7821. * Sets the global Hue value.
  7822. * 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).
  7823. */
  7824. globalHue: number;
  7825. /**
  7826. * Gets the global Density value.
  7827. * 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.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. /**
  7831. * Sets the global Density value.
  7832. * 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.
  7833. * Values less than zero provide a filter of opposite hue.
  7834. */
  7835. globalDensity: number;
  7836. /**
  7837. * Gets the global Saturation value.
  7838. * 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.
  7839. */
  7840. /**
  7841. * Sets the global Saturation value.
  7842. * 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.
  7843. */
  7844. globalSaturation: number;
  7845. /**
  7846. * Gets the global Exposure value.
  7847. * 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.
  7848. */
  7849. /**
  7850. * Sets the global Exposure value.
  7851. * 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.
  7852. */
  7853. globalExposure: number;
  7854. private _highlightsHue;
  7855. private _highlightsDensity;
  7856. private _highlightsSaturation;
  7857. private _highlightsExposure;
  7858. /**
  7859. * Gets the highlights Hue value.
  7860. * 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).
  7861. */
  7862. /**
  7863. * Sets the highlights Hue value.
  7864. * 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).
  7865. */
  7866. highlightsHue: number;
  7867. /**
  7868. * Gets the highlights Density value.
  7869. * 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.
  7870. * Values less than zero provide a filter of opposite hue.
  7871. */
  7872. /**
  7873. * Sets the highlights Density value.
  7874. * 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.
  7875. * Values less than zero provide a filter of opposite hue.
  7876. */
  7877. highlightsDensity: number;
  7878. /**
  7879. * Gets the highlights Saturation value.
  7880. * 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.
  7881. */
  7882. /**
  7883. * Sets the highlights Saturation value.
  7884. * 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.
  7885. */
  7886. highlightsSaturation: number;
  7887. /**
  7888. * Gets the highlights Exposure value.
  7889. * 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.
  7890. */
  7891. /**
  7892. * Sets the highlights Exposure value.
  7893. * 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.
  7894. */
  7895. highlightsExposure: number;
  7896. private _midtonesHue;
  7897. private _midtonesDensity;
  7898. private _midtonesSaturation;
  7899. private _midtonesExposure;
  7900. /**
  7901. * Gets the midtones Hue value.
  7902. * 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).
  7903. */
  7904. /**
  7905. * Sets the midtones Hue value.
  7906. * 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).
  7907. */
  7908. midtonesHue: number;
  7909. /**
  7910. * Gets the midtones Density value.
  7911. * 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.
  7912. * Values less than zero provide a filter of opposite hue.
  7913. */
  7914. /**
  7915. * Sets the midtones Density value.
  7916. * 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.
  7917. * Values less than zero provide a filter of opposite hue.
  7918. */
  7919. midtonesDensity: number;
  7920. /**
  7921. * Gets the midtones Saturation value.
  7922. * 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.
  7923. */
  7924. /**
  7925. * Sets the midtones Saturation value.
  7926. * 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.
  7927. */
  7928. midtonesSaturation: number;
  7929. /**
  7930. * Gets the midtones Exposure value.
  7931. * 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.
  7932. */
  7933. /**
  7934. * Sets the midtones Exposure value.
  7935. * 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.
  7936. */
  7937. midtonesExposure: number;
  7938. private _shadowsHue;
  7939. private _shadowsDensity;
  7940. private _shadowsSaturation;
  7941. private _shadowsExposure;
  7942. /**
  7943. * Gets the shadows Hue value.
  7944. * 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).
  7945. */
  7946. /**
  7947. * Sets the shadows Hue value.
  7948. * 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).
  7949. */
  7950. shadowsHue: number;
  7951. /**
  7952. * Gets the shadows Density value.
  7953. * 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.
  7954. * Values less than zero provide a filter of opposite hue.
  7955. */
  7956. /**
  7957. * Sets the shadows Density value.
  7958. * 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.
  7959. * Values less than zero provide a filter of opposite hue.
  7960. */
  7961. shadowsDensity: number;
  7962. /**
  7963. * Gets the shadows Saturation value.
  7964. * 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.
  7965. */
  7966. /**
  7967. * Sets the shadows Saturation value.
  7968. * 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.
  7969. */
  7970. shadowsSaturation: number;
  7971. /**
  7972. * Gets the shadows Exposure value.
  7973. * 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.
  7974. */
  7975. /**
  7976. * Sets the shadows Exposure value.
  7977. * 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.
  7978. */
  7979. shadowsExposure: number;
  7980. /**
  7981. * Returns the class name
  7982. * @returns The class name
  7983. */
  7984. getClassName(): string;
  7985. /**
  7986. * Binds the color curves to the shader.
  7987. * @param colorCurves The color curve to bind
  7988. * @param effect The effect to bind to
  7989. * @param positiveUniform The positive uniform shader parameter
  7990. * @param neutralUniform The neutral uniform shader parameter
  7991. * @param negativeUniform The negative uniform shader parameter
  7992. */
  7993. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7994. /**
  7995. * Prepare the list of uniforms associated with the ColorCurves effects.
  7996. * @param uniformsList The list of uniforms used in the effect
  7997. */
  7998. static PrepareUniforms(uniformsList: string[]): void;
  7999. /**
  8000. * Returns color grading data based on a hue, density, saturation and exposure value.
  8001. * @param filterHue The hue of the color filter.
  8002. * @param filterDensity The density of the color filter.
  8003. * @param saturation The saturation.
  8004. * @param exposure The exposure.
  8005. * @param result The result data container.
  8006. */
  8007. private getColorGradingDataToRef;
  8008. /**
  8009. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8010. * @param value The input slider value in range [-100,100].
  8011. * @returns Adjusted value.
  8012. */
  8013. private static applyColorGradingSliderNonlinear;
  8014. /**
  8015. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8016. * @param hue The hue (H) input.
  8017. * @param saturation The saturation (S) input.
  8018. * @param brightness The brightness (B) input.
  8019. * @result An RGBA color represented as Vector4.
  8020. */
  8021. private static fromHSBToRef;
  8022. /**
  8023. * Returns a value clamped between min and max
  8024. * @param value The value to clamp
  8025. * @param min The minimum of value
  8026. * @param max The maximum of value
  8027. * @returns The clamped value.
  8028. */
  8029. private static clamp;
  8030. /**
  8031. * Clones the current color curve instance.
  8032. * @return The cloned curves
  8033. */
  8034. clone(): ColorCurves;
  8035. /**
  8036. * Serializes the current color curve instance to a json representation.
  8037. * @return a JSON representation
  8038. */
  8039. serialize(): any;
  8040. /**
  8041. * Parses the color curve from a json representation.
  8042. * @param source the JSON source to parse
  8043. * @return The parsed curves
  8044. */
  8045. static Parse(source: any): ColorCurves;
  8046. }
  8047. }
  8048. declare module BABYLON {
  8049. /**
  8050. * Interface to follow in your material defines to integrate easily the
  8051. * Image proccessing functions.
  8052. * @hidden
  8053. */
  8054. export interface IImageProcessingConfigurationDefines {
  8055. IMAGEPROCESSING: boolean;
  8056. VIGNETTE: boolean;
  8057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8058. VIGNETTEBLENDMODEOPAQUE: boolean;
  8059. TONEMAPPING: boolean;
  8060. TONEMAPPING_ACES: boolean;
  8061. CONTRAST: boolean;
  8062. EXPOSURE: boolean;
  8063. COLORCURVES: boolean;
  8064. COLORGRADING: boolean;
  8065. COLORGRADING3D: boolean;
  8066. SAMPLER3DGREENDEPTH: boolean;
  8067. SAMPLER3DBGRMAP: boolean;
  8068. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8069. }
  8070. /**
  8071. * @hidden
  8072. */
  8073. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8074. IMAGEPROCESSING: boolean;
  8075. VIGNETTE: boolean;
  8076. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8077. VIGNETTEBLENDMODEOPAQUE: boolean;
  8078. TONEMAPPING: boolean;
  8079. TONEMAPPING_ACES: boolean;
  8080. CONTRAST: boolean;
  8081. COLORCURVES: boolean;
  8082. COLORGRADING: boolean;
  8083. COLORGRADING3D: boolean;
  8084. SAMPLER3DGREENDEPTH: boolean;
  8085. SAMPLER3DBGRMAP: boolean;
  8086. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8087. EXPOSURE: boolean;
  8088. constructor();
  8089. }
  8090. /**
  8091. * This groups together the common properties used for image processing either in direct forward pass
  8092. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8093. * or not.
  8094. */
  8095. export class ImageProcessingConfiguration {
  8096. /**
  8097. * Default tone mapping applied in BabylonJS.
  8098. */
  8099. static readonly TONEMAPPING_STANDARD: number;
  8100. /**
  8101. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8102. * to other engines rendering to increase portability.
  8103. */
  8104. static readonly TONEMAPPING_ACES: number;
  8105. /**
  8106. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8107. */
  8108. colorCurves: Nullable<ColorCurves>;
  8109. private _colorCurvesEnabled;
  8110. /**
  8111. * Gets wether the color curves effect is enabled.
  8112. */
  8113. /**
  8114. * Sets wether the color curves effect is enabled.
  8115. */
  8116. colorCurvesEnabled: boolean;
  8117. private _colorGradingTexture;
  8118. /**
  8119. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8120. */
  8121. /**
  8122. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8123. */
  8124. colorGradingTexture: Nullable<BaseTexture>;
  8125. private _colorGradingEnabled;
  8126. /**
  8127. * Gets wether the color grading effect is enabled.
  8128. */
  8129. /**
  8130. * Sets wether the color grading effect is enabled.
  8131. */
  8132. colorGradingEnabled: boolean;
  8133. private _colorGradingWithGreenDepth;
  8134. /**
  8135. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8136. */
  8137. /**
  8138. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8139. */
  8140. colorGradingWithGreenDepth: boolean;
  8141. private _colorGradingBGR;
  8142. /**
  8143. * Gets wether the color grading texture contains BGR values.
  8144. */
  8145. /**
  8146. * Sets wether the color grading texture contains BGR values.
  8147. */
  8148. colorGradingBGR: boolean;
  8149. /** @hidden */
  8150. _exposure: number;
  8151. /**
  8152. * Gets the Exposure used in the effect.
  8153. */
  8154. /**
  8155. * Sets the Exposure used in the effect.
  8156. */
  8157. exposure: number;
  8158. private _toneMappingEnabled;
  8159. /**
  8160. * Gets wether the tone mapping effect is enabled.
  8161. */
  8162. /**
  8163. * Sets wether the tone mapping effect is enabled.
  8164. */
  8165. toneMappingEnabled: boolean;
  8166. private _toneMappingType;
  8167. /**
  8168. * Gets the type of tone mapping effect.
  8169. */
  8170. /**
  8171. * Sets the type of tone mapping effect used in BabylonJS.
  8172. */
  8173. toneMappingType: number;
  8174. protected _contrast: number;
  8175. /**
  8176. * Gets the contrast used in the effect.
  8177. */
  8178. /**
  8179. * Sets the contrast used in the effect.
  8180. */
  8181. contrast: number;
  8182. /**
  8183. * Vignette stretch size.
  8184. */
  8185. vignetteStretch: number;
  8186. /**
  8187. * Vignette centre X Offset.
  8188. */
  8189. vignetteCentreX: number;
  8190. /**
  8191. * Vignette centre Y Offset.
  8192. */
  8193. vignetteCentreY: number;
  8194. /**
  8195. * Vignette weight or intensity of the vignette effect.
  8196. */
  8197. vignetteWeight: number;
  8198. /**
  8199. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8200. * if vignetteEnabled is set to true.
  8201. */
  8202. vignetteColor: Color4;
  8203. /**
  8204. * Camera field of view used by the Vignette effect.
  8205. */
  8206. vignetteCameraFov: number;
  8207. private _vignetteBlendMode;
  8208. /**
  8209. * Gets the vignette blend mode allowing different kind of effect.
  8210. */
  8211. /**
  8212. * Sets the vignette blend mode allowing different kind of effect.
  8213. */
  8214. vignetteBlendMode: number;
  8215. private _vignetteEnabled;
  8216. /**
  8217. * Gets wether the vignette effect is enabled.
  8218. */
  8219. /**
  8220. * Sets wether the vignette effect is enabled.
  8221. */
  8222. vignetteEnabled: boolean;
  8223. private _applyByPostProcess;
  8224. /**
  8225. * Gets wether the image processing is applied through a post process or not.
  8226. */
  8227. /**
  8228. * Sets wether the image processing is applied through a post process or not.
  8229. */
  8230. applyByPostProcess: boolean;
  8231. private _isEnabled;
  8232. /**
  8233. * Gets wether the image processing is enabled or not.
  8234. */
  8235. /**
  8236. * Sets wether the image processing is enabled or not.
  8237. */
  8238. isEnabled: boolean;
  8239. /**
  8240. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8241. */
  8242. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8243. /**
  8244. * Method called each time the image processing information changes requires to recompile the effect.
  8245. */
  8246. protected _updateParameters(): void;
  8247. /**
  8248. * Gets the current class name.
  8249. * @return "ImageProcessingConfiguration"
  8250. */
  8251. getClassName(): string;
  8252. /**
  8253. * Prepare the list of uniforms associated with the Image Processing effects.
  8254. * @param uniforms The list of uniforms used in the effect
  8255. * @param defines the list of defines currently in use
  8256. */
  8257. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8258. /**
  8259. * Prepare the list of samplers associated with the Image Processing effects.
  8260. * @param samplersList The list of uniforms used in the effect
  8261. * @param defines the list of defines currently in use
  8262. */
  8263. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8264. /**
  8265. * Prepare the list of defines associated to the shader.
  8266. * @param defines the list of defines to complete
  8267. * @param forPostProcess Define if we are currently in post process mode or not
  8268. */
  8269. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8270. /**
  8271. * Returns true if all the image processing information are ready.
  8272. * @returns True if ready, otherwise, false
  8273. */
  8274. isReady(): boolean;
  8275. /**
  8276. * Binds the image processing to the shader.
  8277. * @param effect The effect to bind to
  8278. * @param aspectRatio Define the current aspect ratio of the effect
  8279. */
  8280. bind(effect: Effect, aspectRatio?: number): void;
  8281. /**
  8282. * Clones the current image processing instance.
  8283. * @return The cloned image processing
  8284. */
  8285. clone(): ImageProcessingConfiguration;
  8286. /**
  8287. * Serializes the current image processing instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the image processing from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed image processing
  8295. */
  8296. static Parse(source: any): ImageProcessingConfiguration;
  8297. private static _VIGNETTEMODE_MULTIPLY;
  8298. private static _VIGNETTEMODE_OPAQUE;
  8299. /**
  8300. * Used to apply the vignette as a mix with the pixel color.
  8301. */
  8302. static readonly VIGNETTEMODE_MULTIPLY: number;
  8303. /**
  8304. * Used to apply the vignette as a replacement of the pixel color.
  8305. */
  8306. static readonly VIGNETTEMODE_OPAQUE: number;
  8307. }
  8308. }
  8309. declare module BABYLON {
  8310. /** @hidden */
  8311. export var postprocessVertexShader: {
  8312. name: string;
  8313. shader: string;
  8314. };
  8315. }
  8316. declare module BABYLON {
  8317. /** Defines supported spaces */
  8318. export enum Space {
  8319. /** Local (object) space */
  8320. LOCAL = 0,
  8321. /** World space */
  8322. WORLD = 1,
  8323. /** Bone space */
  8324. BONE = 2
  8325. }
  8326. /** Defines the 3 main axes */
  8327. export class Axis {
  8328. /** X axis */
  8329. static X: Vector3;
  8330. /** Y axis */
  8331. static Y: Vector3;
  8332. /** Z axis */
  8333. static Z: Vector3;
  8334. }
  8335. }
  8336. declare module BABYLON {
  8337. /**
  8338. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8339. * This is the base of the follow, arc rotate cameras and Free camera
  8340. * @see http://doc.babylonjs.com/features/cameras
  8341. */
  8342. export class TargetCamera extends Camera {
  8343. private static _RigCamTransformMatrix;
  8344. private static _TargetTransformMatrix;
  8345. private static _TargetFocalPoint;
  8346. /**
  8347. * Define the current direction the camera is moving to
  8348. */
  8349. cameraDirection: Vector3;
  8350. /**
  8351. * Define the current rotation the camera is rotating to
  8352. */
  8353. cameraRotation: Vector2;
  8354. /**
  8355. * When set, the up vector of the camera will be updated by the rotation of the camera
  8356. */
  8357. updateUpVectorFromRotation: boolean;
  8358. private _tmpQuaternion;
  8359. /**
  8360. * Define the current rotation of the camera
  8361. */
  8362. rotation: Vector3;
  8363. /**
  8364. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8365. */
  8366. rotationQuaternion: Quaternion;
  8367. /**
  8368. * Define the current speed of the camera
  8369. */
  8370. speed: number;
  8371. /**
  8372. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8373. * around all axis.
  8374. */
  8375. noRotationConstraint: boolean;
  8376. /**
  8377. * Define the current target of the camera as an object or a position.
  8378. */
  8379. lockedTarget: any;
  8380. /** @hidden */
  8381. _currentTarget: Vector3;
  8382. /** @hidden */
  8383. _initialFocalDistance: number;
  8384. /** @hidden */
  8385. _viewMatrix: Matrix;
  8386. /** @hidden */
  8387. _camMatrix: Matrix;
  8388. /** @hidden */
  8389. _cameraTransformMatrix: Matrix;
  8390. /** @hidden */
  8391. _cameraRotationMatrix: Matrix;
  8392. /** @hidden */
  8393. _referencePoint: Vector3;
  8394. /** @hidden */
  8395. _transformedReferencePoint: Vector3;
  8396. protected _globalCurrentTarget: Vector3;
  8397. protected _globalCurrentUpVector: Vector3;
  8398. /** @hidden */
  8399. _reset: () => void;
  8400. private _defaultUp;
  8401. /**
  8402. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8403. * This is the base of the follow, arc rotate cameras and Free camera
  8404. * @see http://doc.babylonjs.com/features/cameras
  8405. * @param name Defines the name of the camera in the scene
  8406. * @param position Defines the start position of the camera in the scene
  8407. * @param scene Defines the scene the camera belongs to
  8408. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8409. */
  8410. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8411. /**
  8412. * Gets the position in front of the camera at a given distance.
  8413. * @param distance The distance from the camera we want the position to be
  8414. * @returns the position
  8415. */
  8416. getFrontPosition(distance: number): Vector3;
  8417. /** @hidden */
  8418. _getLockedTargetPosition(): Nullable<Vector3>;
  8419. private _storedPosition;
  8420. private _storedRotation;
  8421. private _storedRotationQuaternion;
  8422. /**
  8423. * Store current camera state of the camera (fov, position, rotation, etc..)
  8424. * @returns the camera
  8425. */
  8426. storeState(): Camera;
  8427. /**
  8428. * Restored camera state. You must call storeState() first
  8429. * @returns whether it was successful or not
  8430. * @hidden
  8431. */
  8432. _restoreStateValues(): boolean;
  8433. /** @hidden */
  8434. _initCache(): void;
  8435. /** @hidden */
  8436. _updateCache(ignoreParentClass?: boolean): void;
  8437. /** @hidden */
  8438. _isSynchronizedViewMatrix(): boolean;
  8439. /** @hidden */
  8440. _computeLocalCameraSpeed(): number;
  8441. /**
  8442. * Defines the target the camera should look at.
  8443. * @param target Defines the new target as a Vector or a mesh
  8444. */
  8445. setTarget(target: Vector3): void;
  8446. /**
  8447. * Return the current target position of the camera. This value is expressed in local space.
  8448. * @returns the target position
  8449. */
  8450. getTarget(): Vector3;
  8451. /** @hidden */
  8452. _decideIfNeedsToMove(): boolean;
  8453. /** @hidden */
  8454. _updatePosition(): void;
  8455. /** @hidden */
  8456. _checkInputs(): void;
  8457. protected _updateCameraRotationMatrix(): void;
  8458. /**
  8459. * 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)
  8460. * @returns the current camera
  8461. */
  8462. private _rotateUpVectorWithCameraRotationMatrix;
  8463. private _cachedRotationZ;
  8464. private _cachedQuaternionRotationZ;
  8465. /** @hidden */
  8466. _getViewMatrix(): Matrix;
  8467. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8468. /**
  8469. * @hidden
  8470. */
  8471. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8472. /**
  8473. * @hidden
  8474. */
  8475. _updateRigCameras(): void;
  8476. private _getRigCamPositionAndTarget;
  8477. /**
  8478. * Gets the current object class name.
  8479. * @return the class name
  8480. */
  8481. getClassName(): string;
  8482. }
  8483. }
  8484. declare module BABYLON {
  8485. /**
  8486. * Gather the list of keyboard event types as constants.
  8487. */
  8488. export class KeyboardEventTypes {
  8489. /**
  8490. * The keydown event is fired when a key becomes active (pressed).
  8491. */
  8492. static readonly KEYDOWN: number;
  8493. /**
  8494. * The keyup event is fired when a key has been released.
  8495. */
  8496. static readonly KEYUP: number;
  8497. }
  8498. /**
  8499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8500. */
  8501. export class KeyboardInfo {
  8502. /**
  8503. * Defines the type of event (KeyboardEventTypes)
  8504. */
  8505. type: number;
  8506. /**
  8507. * Defines the related dom event
  8508. */
  8509. event: KeyboardEvent;
  8510. /**
  8511. * Instantiates a new keyboard info.
  8512. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8513. * @param type Defines the type of event (KeyboardEventTypes)
  8514. * @param event Defines the related dom event
  8515. */
  8516. constructor(
  8517. /**
  8518. * Defines the type of event (KeyboardEventTypes)
  8519. */
  8520. type: number,
  8521. /**
  8522. * Defines the related dom event
  8523. */
  8524. event: KeyboardEvent);
  8525. }
  8526. /**
  8527. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8528. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8529. */
  8530. export class KeyboardInfoPre extends KeyboardInfo {
  8531. /**
  8532. * Defines the type of event (KeyboardEventTypes)
  8533. */
  8534. type: number;
  8535. /**
  8536. * Defines the related dom event
  8537. */
  8538. event: KeyboardEvent;
  8539. /**
  8540. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8541. */
  8542. skipOnPointerObservable: boolean;
  8543. /**
  8544. * Instantiates a new keyboard pre info.
  8545. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8546. * @param type Defines the type of event (KeyboardEventTypes)
  8547. * @param event Defines the related dom event
  8548. */
  8549. constructor(
  8550. /**
  8551. * Defines the type of event (KeyboardEventTypes)
  8552. */
  8553. type: number,
  8554. /**
  8555. * Defines the related dom event
  8556. */
  8557. event: KeyboardEvent);
  8558. }
  8559. }
  8560. declare module BABYLON {
  8561. /**
  8562. * Manage the keyboard inputs to control the movement of a free camera.
  8563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8564. */
  8565. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8566. /**
  8567. * Defines the camera the input is attached to.
  8568. */
  8569. camera: FreeCamera;
  8570. /**
  8571. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8572. */
  8573. keysUp: number[];
  8574. /**
  8575. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8576. */
  8577. keysDown: number[];
  8578. /**
  8579. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8580. */
  8581. keysLeft: number[];
  8582. /**
  8583. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8584. */
  8585. keysRight: number[];
  8586. private _keys;
  8587. private _onCanvasBlurObserver;
  8588. private _onKeyboardObserver;
  8589. private _engine;
  8590. private _scene;
  8591. /**
  8592. * Attach the input controls to a specific dom element to get the input from.
  8593. * @param element Defines the element the controls should be listened from
  8594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8595. */
  8596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8597. /**
  8598. * Detach the current controls from the specified dom element.
  8599. * @param element Defines the element to stop listening the inputs from
  8600. */
  8601. detachControl(element: Nullable<HTMLElement>): void;
  8602. /**
  8603. * Update the current camera state depending on the inputs that have been used this frame.
  8604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8605. */
  8606. checkInputs(): void;
  8607. /**
  8608. * Gets the class name of the current intput.
  8609. * @returns the class name
  8610. */
  8611. getClassName(): string;
  8612. /** @hidden */
  8613. _onLostFocus(): void;
  8614. /**
  8615. * Get the friendly name associated with the input class.
  8616. * @returns the input friendly name
  8617. */
  8618. getSimpleName(): string;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * "Static Class" containing the most commonly used helper while dealing with material for
  8860. * rendering purpose.
  8861. *
  8862. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8863. *
  8864. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8865. */
  8866. export class MaterialHelper {
  8867. /**
  8868. * Bind the current view position to an effect.
  8869. * @param effect The effect to be bound
  8870. * @param scene The scene the eyes position is used from
  8871. */
  8872. static BindEyePosition(effect: Effect, scene: Scene): void;
  8873. /**
  8874. * Helps preparing the defines values about the UVs in used in the effect.
  8875. * UVs are shared as much as we can accross channels in the shaders.
  8876. * @param texture The texture we are preparing the UVs for
  8877. * @param defines The defines to update
  8878. * @param key The channel key "diffuse", "specular"... used in the shader
  8879. */
  8880. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8881. /**
  8882. * Binds a texture matrix value to its corrsponding uniform
  8883. * @param texture The texture to bind the matrix for
  8884. * @param uniformBuffer The uniform buffer receivin the data
  8885. * @param key The channel key "diffuse", "specular"... used in the shader
  8886. */
  8887. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8888. /**
  8889. * Gets the current status of the fog (should it be enabled?)
  8890. * @param mesh defines the mesh to evaluate for fog support
  8891. * @param scene defines the hosting scene
  8892. * @returns true if fog must be enabled
  8893. */
  8894. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8895. /**
  8896. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8897. * @param mesh defines the current mesh
  8898. * @param scene defines the current scene
  8899. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8900. * @param pointsCloud defines if point cloud rendering has to be turned on
  8901. * @param fogEnabled defines if fog has to be turned on
  8902. * @param alphaTest defines if alpha testing has to be turned on
  8903. * @param defines defines the current list of defines
  8904. */
  8905. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8906. /**
  8907. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8908. * @param scene defines the current scene
  8909. * @param engine defines the current engine
  8910. * @param defines specifies the list of active defines
  8911. * @param useInstances defines if instances have to be turned on
  8912. * @param useClipPlane defines if clip plane have to be turned on
  8913. */
  8914. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8915. /**
  8916. * Prepares the defines for bones
  8917. * @param mesh The mesh containing the geometry data we will draw
  8918. * @param defines The defines to update
  8919. */
  8920. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8921. /**
  8922. * Prepares the defines for morph targets
  8923. * @param mesh The mesh containing the geometry data we will draw
  8924. * @param defines The defines to update
  8925. */
  8926. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8927. /**
  8928. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8929. * @param mesh The mesh containing the geometry data we will draw
  8930. * @param defines The defines to update
  8931. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8932. * @param useBones Precise whether bones should be used or not (override mesh info)
  8933. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8934. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8935. * @returns false if defines are considered not dirty and have not been checked
  8936. */
  8937. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8938. /**
  8939. * Prepares the defines related to multiview
  8940. * @param scene The scene we are intending to draw
  8941. * @param defines The defines to update
  8942. */
  8943. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8944. /**
  8945. * Prepares the defines related to the light information passed in parameter
  8946. * @param scene The scene we are intending to draw
  8947. * @param mesh The mesh the effect is compiling for
  8948. * @param light The light the effect is compiling for
  8949. * @param lightIndex The index of the light
  8950. * @param defines The defines to update
  8951. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8952. * @param state Defines the current state regarding what is needed (normals, etc...)
  8953. */
  8954. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8955. needNormals: boolean;
  8956. needRebuild: boolean;
  8957. shadowEnabled: boolean;
  8958. specularEnabled: boolean;
  8959. lightmapMode: boolean;
  8960. }): void;
  8961. /**
  8962. * Prepares the defines related to the light information passed in parameter
  8963. * @param scene The scene we are intending to draw
  8964. * @param mesh The mesh the effect is compiling for
  8965. * @param defines The defines to update
  8966. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8967. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8968. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8969. * @returns true if normals will be required for the rest of the effect
  8970. */
  8971. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8972. /**
  8973. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8974. * @param lightIndex defines the light index
  8975. * @param uniformsList The uniform list
  8976. * @param samplersList The sampler list
  8977. * @param projectedLightTexture defines if projected texture must be used
  8978. * @param uniformBuffersList defines an optional list of uniform buffers
  8979. */
  8980. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect
  8983. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8984. * @param samplersList The sampler list
  8985. * @param defines The defines helping in the list generation
  8986. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8987. */
  8988. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8989. /**
  8990. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8991. * @param defines The defines to update while falling back
  8992. * @param fallbacks The authorized effect fallbacks
  8993. * @param maxSimultaneousLights The maximum number of lights allowed
  8994. * @param rank the current rank of the Effect
  8995. * @returns The newly affected rank
  8996. */
  8997. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8998. private static _TmpMorphInfluencers;
  8999. /**
  9000. * Prepares the list of attributes required for morph targets according to the effect defines.
  9001. * @param attribs The current list of supported attribs
  9002. * @param mesh The mesh to prepare the morph targets attributes for
  9003. * @param influencers The number of influencers
  9004. */
  9005. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9006. /**
  9007. * Prepares the list of attributes required for morph targets according to the effect defines.
  9008. * @param attribs The current list of supported attribs
  9009. * @param mesh The mesh to prepare the morph targets attributes for
  9010. * @param defines The current Defines of the effect
  9011. */
  9012. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9013. /**
  9014. * Prepares the list of attributes required for bones according to the effect defines.
  9015. * @param attribs The current list of supported attribs
  9016. * @param mesh The mesh to prepare the bones attributes for
  9017. * @param defines The current Defines of the effect
  9018. * @param fallbacks The current efffect fallback strategy
  9019. */
  9020. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9021. /**
  9022. * Check and prepare the list of attributes required for instances according to the effect defines.
  9023. * @param attribs The current list of supported attribs
  9024. * @param defines The current MaterialDefines of the effect
  9025. */
  9026. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9027. /**
  9028. * Add the list of attributes required for instances to the attribs array.
  9029. * @param attribs The current list of supported attribs
  9030. */
  9031. static PushAttributesForInstances(attribs: string[]): void;
  9032. /**
  9033. * Binds the light shadow information to the effect for the given mesh.
  9034. * @param light The light containing the generator
  9035. * @param scene The scene the lights belongs to
  9036. * @param mesh The mesh we are binding the information to render
  9037. * @param lightIndex The light index in the effect used to render the mesh
  9038. * @param effect The effect we are binding the data to
  9039. */
  9040. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9041. /**
  9042. * Binds the light information to the effect.
  9043. * @param light The light containing the generator
  9044. * @param effect The effect we are binding the data to
  9045. * @param lightIndex The light index in the effect used to render
  9046. */
  9047. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9048. /**
  9049. * Binds the lights information from the scene to the effect for the given mesh.
  9050. * @param light Light to bind
  9051. * @param lightIndex Light index
  9052. * @param scene The scene where the light belongs to
  9053. * @param mesh The mesh we are binding the information to render
  9054. * @param effect The effect we are binding the data to
  9055. * @param useSpecular Defines if specular is supported
  9056. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9057. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9058. */
  9059. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9060. /**
  9061. * Binds the lights information from the scene to the effect for the given mesh.
  9062. * @param scene The scene the lights belongs to
  9063. * @param mesh The mesh we are binding the information to render
  9064. * @param effect The effect we are binding the data to
  9065. * @param defines The generated defines for the effect
  9066. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9067. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9068. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9069. */
  9070. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9071. private static _tempFogColor;
  9072. /**
  9073. * Binds the fog information from the scene to the effect for the given mesh.
  9074. * @param scene The scene the lights belongs to
  9075. * @param mesh The mesh we are binding the information to render
  9076. * @param effect The effect we are binding the data to
  9077. * @param linearSpace Defines if the fog effect is applied in linear space
  9078. */
  9079. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9080. /**
  9081. * Binds the bones information from the mesh to the effect.
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. */
  9085. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9086. /**
  9087. * Binds the morph targets information from the mesh to the effect.
  9088. * @param abstractMesh The mesh we are binding the information to render
  9089. * @param effect The effect we are binding the data to
  9090. */
  9091. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9092. /**
  9093. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9094. * @param defines The generated defines used in the effect
  9095. * @param effect The effect we are binding the data to
  9096. * @param scene The scene we are willing to render with logarithmic scale for
  9097. */
  9098. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9099. /**
  9100. * Binds the clip plane information from the scene to the effect.
  9101. * @param scene The scene the clip plane information are extracted from
  9102. * @param effect The effect we are binding the data to
  9103. */
  9104. static BindClipPlane(effect: Effect, scene: Scene): void;
  9105. }
  9106. }
  9107. declare module BABYLON {
  9108. /** @hidden */
  9109. export var packingFunctions: {
  9110. name: string;
  9111. shader: string;
  9112. };
  9113. }
  9114. declare module BABYLON {
  9115. /** @hidden */
  9116. export var shadowMapPixelShader: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module BABYLON {
  9122. /** @hidden */
  9123. export var bonesDeclaration: {
  9124. name: string;
  9125. shader: string;
  9126. };
  9127. }
  9128. declare module BABYLON {
  9129. /** @hidden */
  9130. export var morphTargetsVertexGlobalDeclaration: {
  9131. name: string;
  9132. shader: string;
  9133. };
  9134. }
  9135. declare module BABYLON {
  9136. /** @hidden */
  9137. export var morphTargetsVertexDeclaration: {
  9138. name: string;
  9139. shader: string;
  9140. };
  9141. }
  9142. declare module BABYLON {
  9143. /** @hidden */
  9144. export var instancesDeclaration: {
  9145. name: string;
  9146. shader: string;
  9147. };
  9148. }
  9149. declare module BABYLON {
  9150. /** @hidden */
  9151. export var helperFunctions: {
  9152. name: string;
  9153. shader: string;
  9154. };
  9155. }
  9156. declare module BABYLON {
  9157. /** @hidden */
  9158. export var morphTargetsVertex: {
  9159. name: string;
  9160. shader: string;
  9161. };
  9162. }
  9163. declare module BABYLON {
  9164. /** @hidden */
  9165. export var instancesVertex: {
  9166. name: string;
  9167. shader: string;
  9168. };
  9169. }
  9170. declare module BABYLON {
  9171. /** @hidden */
  9172. export var bonesVertex: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module BABYLON {
  9178. /** @hidden */
  9179. export var shadowMapVertexShader: {
  9180. name: string;
  9181. shader: string;
  9182. };
  9183. }
  9184. declare module BABYLON {
  9185. /** @hidden */
  9186. export var depthBoxBlurPixelShader: {
  9187. name: string;
  9188. shader: string;
  9189. };
  9190. }
  9191. declare module BABYLON {
  9192. /**
  9193. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9194. */
  9195. export interface ICustomShaderOptions {
  9196. /**
  9197. * Gets or sets the custom shader name to use
  9198. */
  9199. shaderName: string;
  9200. /**
  9201. * The list of attribute names used in the shader
  9202. */
  9203. attributes?: string[];
  9204. /**
  9205. * The list of unifrom names used in the shader
  9206. */
  9207. uniforms?: string[];
  9208. /**
  9209. * The list of sampler names used in the shader
  9210. */
  9211. samplers?: string[];
  9212. /**
  9213. * The list of defines used in the shader
  9214. */
  9215. defines?: string[];
  9216. }
  9217. /**
  9218. * Interface to implement to create a shadow generator compatible with BJS.
  9219. */
  9220. export interface IShadowGenerator {
  9221. /**
  9222. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9223. * @returns The render target texture if present otherwise, null
  9224. */
  9225. getShadowMap(): Nullable<RenderTargetTexture>;
  9226. /**
  9227. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9228. * @returns The render target texture if the shadow map is present otherwise, null
  9229. */
  9230. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9231. /**
  9232. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9233. * @param subMesh The submesh we want to render in the shadow map
  9234. * @param useInstances Defines wether will draw in the map using instances
  9235. * @returns true if ready otherwise, false
  9236. */
  9237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9238. /**
  9239. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9240. * @param defines Defines of the material we want to update
  9241. * @param lightIndex Index of the light in the enabled light list of the material
  9242. */
  9243. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9244. /**
  9245. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9246. * defined in the generator but impacting the effect).
  9247. * It implies the unifroms available on the materials are the standard BJS ones.
  9248. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9249. * @param effect The effect we are binfing the information for
  9250. */
  9251. bindShadowLight(lightIndex: string, effect: Effect): void;
  9252. /**
  9253. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9254. * (eq to shadow prjection matrix * light transform matrix)
  9255. * @returns The transform matrix used to create the shadow map
  9256. */
  9257. getTransformMatrix(): Matrix;
  9258. /**
  9259. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9260. * Cube and 2D textures for instance.
  9261. */
  9262. recreateShadowMap(): void;
  9263. /**
  9264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9265. * @param onCompiled Callback triggered at the and of the effects compilation
  9266. * @param options Sets of optional options forcing the compilation with different modes
  9267. */
  9268. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9269. useInstances: boolean;
  9270. }>): void;
  9271. /**
  9272. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9273. * @param options Sets of optional options forcing the compilation with different modes
  9274. * @returns A promise that resolves when the compilation completes
  9275. */
  9276. forceCompilationAsync(options?: Partial<{
  9277. useInstances: boolean;
  9278. }>): Promise<void>;
  9279. /**
  9280. * Serializes the shadow generator setup to a json object.
  9281. * @returns The serialized JSON object
  9282. */
  9283. serialize(): any;
  9284. /**
  9285. * Disposes the Shadow map and related Textures and effects.
  9286. */
  9287. dispose(): void;
  9288. }
  9289. /**
  9290. * Default implementation IShadowGenerator.
  9291. * This is the main object responsible of generating shadows in the framework.
  9292. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9293. */
  9294. export class ShadowGenerator implements IShadowGenerator {
  9295. /**
  9296. * Shadow generator mode None: no filtering applied.
  9297. */
  9298. static readonly FILTER_NONE: number;
  9299. /**
  9300. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9301. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9302. */
  9303. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9304. /**
  9305. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9306. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9307. */
  9308. static readonly FILTER_POISSONSAMPLING: number;
  9309. /**
  9310. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9311. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9312. */
  9313. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9314. /**
  9315. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9316. * edge artifacts on steep falloff.
  9317. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9318. */
  9319. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9320. /**
  9321. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9322. * edge artifacts on steep falloff.
  9323. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9324. */
  9325. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9326. /**
  9327. * Shadow generator mode PCF: Percentage Closer Filtering
  9328. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9329. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9330. */
  9331. static readonly FILTER_PCF: number;
  9332. /**
  9333. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9334. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9335. * Contact Hardening
  9336. */
  9337. static readonly FILTER_PCSS: number;
  9338. /**
  9339. * Reserved for PCF and PCSS
  9340. * Highest Quality.
  9341. *
  9342. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9343. *
  9344. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9345. */
  9346. static readonly QUALITY_HIGH: number;
  9347. /**
  9348. * Reserved for PCF and PCSS
  9349. * Good tradeoff for quality/perf cross devices
  9350. *
  9351. * Execute PCF on a 3*3 kernel.
  9352. *
  9353. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9354. */
  9355. static readonly QUALITY_MEDIUM: number;
  9356. /**
  9357. * Reserved for PCF and PCSS
  9358. * The lowest quality but the fastest.
  9359. *
  9360. * Execute PCF on a 1*1 kernel.
  9361. *
  9362. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9363. */
  9364. static readonly QUALITY_LOW: number;
  9365. /** Gets or sets the custom shader name to use */
  9366. customShaderOptions: ICustomShaderOptions;
  9367. /**
  9368. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9369. */
  9370. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9371. /**
  9372. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9373. */
  9374. onAfterShadowMapRenderObservable: Observable<Effect>;
  9375. /**
  9376. * Observable triggered before a mesh is rendered in the shadow map.
  9377. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9378. */
  9379. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9380. /**
  9381. * Observable triggered after a mesh is rendered in the shadow map.
  9382. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9383. */
  9384. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9385. private _bias;
  9386. /**
  9387. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9388. */
  9389. /**
  9390. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9391. */
  9392. bias: number;
  9393. private _normalBias;
  9394. /**
  9395. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9396. */
  9397. /**
  9398. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9399. */
  9400. normalBias: number;
  9401. private _blurBoxOffset;
  9402. /**
  9403. * Gets the blur box offset: offset applied during the blur pass.
  9404. * Only useful if useKernelBlur = false
  9405. */
  9406. /**
  9407. * Sets the blur box offset: offset applied during the blur pass.
  9408. * Only useful if useKernelBlur = false
  9409. */
  9410. blurBoxOffset: number;
  9411. private _blurScale;
  9412. /**
  9413. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9414. * 2 means half of the size.
  9415. */
  9416. /**
  9417. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9418. * 2 means half of the size.
  9419. */
  9420. blurScale: number;
  9421. private _blurKernel;
  9422. /**
  9423. * Gets the blur kernel: kernel size of the blur pass.
  9424. * Only useful if useKernelBlur = true
  9425. */
  9426. /**
  9427. * Sets the blur kernel: kernel size of the blur pass.
  9428. * Only useful if useKernelBlur = true
  9429. */
  9430. blurKernel: number;
  9431. private _useKernelBlur;
  9432. /**
  9433. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9434. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9435. */
  9436. /**
  9437. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9438. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9439. */
  9440. useKernelBlur: boolean;
  9441. private _depthScale;
  9442. /**
  9443. * Gets the depth scale used in ESM mode.
  9444. */
  9445. /**
  9446. * Sets the depth scale used in ESM mode.
  9447. * This can override the scale stored on the light.
  9448. */
  9449. depthScale: number;
  9450. private _filter;
  9451. /**
  9452. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9453. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9454. */
  9455. /**
  9456. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9457. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9458. */
  9459. filter: number;
  9460. /**
  9461. * Gets if the current filter is set to Poisson Sampling.
  9462. */
  9463. /**
  9464. * Sets the current filter to Poisson Sampling.
  9465. */
  9466. usePoissonSampling: boolean;
  9467. /**
  9468. * Gets if the current filter is set to ESM.
  9469. */
  9470. /**
  9471. * Sets the current filter is to ESM.
  9472. */
  9473. useExponentialShadowMap: boolean;
  9474. /**
  9475. * Gets if the current filter is set to filtered ESM.
  9476. */
  9477. /**
  9478. * Gets if the current filter is set to filtered ESM.
  9479. */
  9480. useBlurExponentialShadowMap: boolean;
  9481. /**
  9482. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9483. * exponential to prevent steep falloff artifacts).
  9484. */
  9485. /**
  9486. * Sets the current filter to "close ESM" (using the inverse of the
  9487. * exponential to prevent steep falloff artifacts).
  9488. */
  9489. useCloseExponentialShadowMap: boolean;
  9490. /**
  9491. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9492. * exponential to prevent steep falloff artifacts).
  9493. */
  9494. /**
  9495. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9496. * exponential to prevent steep falloff artifacts).
  9497. */
  9498. useBlurCloseExponentialShadowMap: boolean;
  9499. /**
  9500. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9501. */
  9502. /**
  9503. * Sets the current filter to "PCF" (percentage closer filtering).
  9504. */
  9505. usePercentageCloserFiltering: boolean;
  9506. private _filteringQuality;
  9507. /**
  9508. * Gets the PCF or PCSS Quality.
  9509. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9510. */
  9511. /**
  9512. * Sets the PCF or PCSS Quality.
  9513. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9514. */
  9515. filteringQuality: number;
  9516. /**
  9517. * Gets if the current filter is set to "PCSS" (contact hardening).
  9518. */
  9519. /**
  9520. * Sets the current filter to "PCSS" (contact hardening).
  9521. */
  9522. useContactHardeningShadow: boolean;
  9523. private _contactHardeningLightSizeUVRatio;
  9524. /**
  9525. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9526. * Using a ratio helps keeping shape stability independently of the map size.
  9527. *
  9528. * It does not account for the light projection as it was having too much
  9529. * instability during the light setup or during light position changes.
  9530. *
  9531. * Only valid if useContactHardeningShadow is true.
  9532. */
  9533. /**
  9534. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9535. * Using a ratio helps keeping shape stability independently of the map size.
  9536. *
  9537. * It does not account for the light projection as it was having too much
  9538. * instability during the light setup or during light position changes.
  9539. *
  9540. * Only valid if useContactHardeningShadow is true.
  9541. */
  9542. contactHardeningLightSizeUVRatio: number;
  9543. private _darkness;
  9544. /** Gets or sets the actual darkness of a shadow */
  9545. darkness: number;
  9546. /**
  9547. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9548. * 0 means strongest and 1 would means no shadow.
  9549. * @returns the darkness.
  9550. */
  9551. getDarkness(): number;
  9552. /**
  9553. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9554. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9555. * @returns the shadow generator allowing fluent coding.
  9556. */
  9557. setDarkness(darkness: number): ShadowGenerator;
  9558. private _transparencyShadow;
  9559. /** Gets or sets the ability to have transparent shadow */
  9560. transparencyShadow: boolean;
  9561. /**
  9562. * Sets the ability to have transparent shadow (boolean).
  9563. * @param transparent True if transparent else False
  9564. * @returns the shadow generator allowing fluent coding
  9565. */
  9566. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9567. private _shadowMap;
  9568. private _shadowMap2;
  9569. /**
  9570. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9571. * @returns The render target texture if present otherwise, null
  9572. */
  9573. getShadowMap(): Nullable<RenderTargetTexture>;
  9574. /**
  9575. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9576. * @returns The render target texture if the shadow map is present otherwise, null
  9577. */
  9578. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9579. /**
  9580. * Gets the class name of that object
  9581. * @returns "ShadowGenerator"
  9582. */
  9583. getClassName(): string;
  9584. /**
  9585. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9586. * @param mesh Mesh to add
  9587. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9588. * @returns the Shadow Generator itself
  9589. */
  9590. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9591. /**
  9592. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9593. * @param mesh Mesh to remove
  9594. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9595. * @returns the Shadow Generator itself
  9596. */
  9597. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9598. /**
  9599. * Controls the extent to which the shadows fade out at the edge of the frustum
  9600. * Used only by directionals and spots
  9601. */
  9602. frustumEdgeFalloff: number;
  9603. private _light;
  9604. /**
  9605. * Returns the associated light object.
  9606. * @returns the light generating the shadow
  9607. */
  9608. getLight(): IShadowLight;
  9609. /**
  9610. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9611. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9612. * It might on the other hand introduce peter panning.
  9613. */
  9614. forceBackFacesOnly: boolean;
  9615. private _scene;
  9616. private _lightDirection;
  9617. private _effect;
  9618. private _viewMatrix;
  9619. private _projectionMatrix;
  9620. private _transformMatrix;
  9621. private _cachedPosition;
  9622. private _cachedDirection;
  9623. private _cachedDefines;
  9624. private _currentRenderID;
  9625. private _boxBlurPostprocess;
  9626. private _kernelBlurXPostprocess;
  9627. private _kernelBlurYPostprocess;
  9628. private _blurPostProcesses;
  9629. private _mapSize;
  9630. private _currentFaceIndex;
  9631. private _currentFaceIndexCache;
  9632. private _textureType;
  9633. private _defaultTextureMatrix;
  9634. /** @hidden */
  9635. static _SceneComponentInitialization: (scene: Scene) => void;
  9636. /**
  9637. * Creates a ShadowGenerator object.
  9638. * A ShadowGenerator is the required tool to use the shadows.
  9639. * Each light casting shadows needs to use its own ShadowGenerator.
  9640. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9641. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9642. * @param light The light object generating the shadows.
  9643. * @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.
  9644. */
  9645. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9646. private _initializeGenerator;
  9647. private _initializeShadowMap;
  9648. private _initializeBlurRTTAndPostProcesses;
  9649. private _renderForShadowMap;
  9650. private _renderSubMeshForShadowMap;
  9651. private _applyFilterValues;
  9652. /**
  9653. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9654. * @param onCompiled Callback triggered at the and of the effects compilation
  9655. * @param options Sets of optional options forcing the compilation with different modes
  9656. */
  9657. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9658. useInstances: boolean;
  9659. }>): void;
  9660. /**
  9661. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9662. * @param options Sets of optional options forcing the compilation with different modes
  9663. * @returns A promise that resolves when the compilation completes
  9664. */
  9665. forceCompilationAsync(options?: Partial<{
  9666. useInstances: boolean;
  9667. }>): Promise<void>;
  9668. /**
  9669. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9670. * @param subMesh The submesh we want to render in the shadow map
  9671. * @param useInstances Defines wether will draw in the map using instances
  9672. * @returns true if ready otherwise, false
  9673. */
  9674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9675. /**
  9676. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9677. * @param defines Defines of the material we want to update
  9678. * @param lightIndex Index of the light in the enabled light list of the material
  9679. */
  9680. prepareDefines(defines: any, lightIndex: number): void;
  9681. /**
  9682. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9683. * defined in the generator but impacting the effect).
  9684. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9685. * @param effect The effect we are binfing the information for
  9686. */
  9687. bindShadowLight(lightIndex: string, effect: Effect): void;
  9688. /**
  9689. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9690. * (eq to shadow prjection matrix * light transform matrix)
  9691. * @returns The transform matrix used to create the shadow map
  9692. */
  9693. getTransformMatrix(): Matrix;
  9694. /**
  9695. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9696. * Cube and 2D textures for instance.
  9697. */
  9698. recreateShadowMap(): void;
  9699. private _disposeBlurPostProcesses;
  9700. private _disposeRTTandPostProcesses;
  9701. /**
  9702. * Disposes the ShadowGenerator.
  9703. * Returns nothing.
  9704. */
  9705. dispose(): void;
  9706. /**
  9707. * Serializes the shadow generator setup to a json object.
  9708. * @returns The serialized JSON object
  9709. */
  9710. serialize(): any;
  9711. /**
  9712. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9713. * @param parsedShadowGenerator The JSON object to parse
  9714. * @param scene The scene to create the shadow map for
  9715. * @returns The parsed shadow generator
  9716. */
  9717. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9718. }
  9719. }
  9720. declare module BABYLON {
  9721. /**
  9722. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9723. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9724. * 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.
  9725. */
  9726. export abstract class Light extends Node {
  9727. /**
  9728. * Falloff Default: light is falling off following the material specification:
  9729. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9730. */
  9731. static readonly FALLOFF_DEFAULT: number;
  9732. /**
  9733. * Falloff Physical: light is falling off following the inverse squared distance law.
  9734. */
  9735. static readonly FALLOFF_PHYSICAL: number;
  9736. /**
  9737. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9738. * to enhance interoperability with other engines.
  9739. */
  9740. static readonly FALLOFF_GLTF: number;
  9741. /**
  9742. * Falloff Standard: light is falling off like in the standard material
  9743. * to enhance interoperability with other materials.
  9744. */
  9745. static readonly FALLOFF_STANDARD: number;
  9746. /**
  9747. * If every light affecting the material is in this lightmapMode,
  9748. * material.lightmapTexture adds or multiplies
  9749. * (depends on material.useLightmapAsShadowmap)
  9750. * after every other light calculations.
  9751. */
  9752. static readonly LIGHTMAP_DEFAULT: number;
  9753. /**
  9754. * material.lightmapTexture as only diffuse lighting from this light
  9755. * adds only specular lighting from this light
  9756. * adds dynamic shadows
  9757. */
  9758. static readonly LIGHTMAP_SPECULAR: number;
  9759. /**
  9760. * material.lightmapTexture as only lighting
  9761. * no light calculation from this light
  9762. * only adds dynamic shadows from this light
  9763. */
  9764. static readonly LIGHTMAP_SHADOWSONLY: number;
  9765. /**
  9766. * Each light type uses the default quantity according to its type:
  9767. * point/spot lights use luminous intensity
  9768. * directional lights use illuminance
  9769. */
  9770. static readonly INTENSITYMODE_AUTOMATIC: number;
  9771. /**
  9772. * lumen (lm)
  9773. */
  9774. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9775. /**
  9776. * candela (lm/sr)
  9777. */
  9778. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9779. /**
  9780. * lux (lm/m^2)
  9781. */
  9782. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9783. /**
  9784. * nit (cd/m^2)
  9785. */
  9786. static readonly INTENSITYMODE_LUMINANCE: number;
  9787. /**
  9788. * Light type const id of the point light.
  9789. */
  9790. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9791. /**
  9792. * Light type const id of the directional light.
  9793. */
  9794. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9795. /**
  9796. * Light type const id of the spot light.
  9797. */
  9798. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9799. /**
  9800. * Light type const id of the hemispheric light.
  9801. */
  9802. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9803. /**
  9804. * Diffuse gives the basic color to an object.
  9805. */
  9806. diffuse: Color3;
  9807. /**
  9808. * Specular produces a highlight color on an object.
  9809. * Note: This is note affecting PBR materials.
  9810. */
  9811. specular: Color3;
  9812. /**
  9813. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9814. * falling off base on range or angle.
  9815. * This can be set to any values in Light.FALLOFF_x.
  9816. *
  9817. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9818. * other types of materials.
  9819. */
  9820. falloffType: number;
  9821. /**
  9822. * Strength of the light.
  9823. * Note: By default it is define in the framework own unit.
  9824. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9825. */
  9826. intensity: number;
  9827. private _range;
  9828. protected _inverseSquaredRange: number;
  9829. /**
  9830. * Defines how far from the source the light is impacting in scene units.
  9831. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9832. */
  9833. /**
  9834. * Defines how far from the source the light is impacting in scene units.
  9835. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9836. */
  9837. range: number;
  9838. /**
  9839. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9840. * of light.
  9841. */
  9842. private _photometricScale;
  9843. private _intensityMode;
  9844. /**
  9845. * Gets the photometric scale used to interpret the intensity.
  9846. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9847. */
  9848. /**
  9849. * Sets the photometric scale used to interpret the intensity.
  9850. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9851. */
  9852. intensityMode: number;
  9853. private _radius;
  9854. /**
  9855. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9856. */
  9857. /**
  9858. * sets the light radius used by PBR Materials to simulate soft area lights.
  9859. */
  9860. radius: number;
  9861. private _renderPriority;
  9862. /**
  9863. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9864. * exceeding the number allowed of the materials.
  9865. */
  9866. renderPriority: number;
  9867. private _shadowEnabled;
  9868. /**
  9869. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9870. * the current shadow generator.
  9871. */
  9872. /**
  9873. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9874. * the current shadow generator.
  9875. */
  9876. shadowEnabled: boolean;
  9877. private _includedOnlyMeshes;
  9878. /**
  9879. * Gets the only meshes impacted by this light.
  9880. */
  9881. /**
  9882. * Sets the only meshes impacted by this light.
  9883. */
  9884. includedOnlyMeshes: AbstractMesh[];
  9885. private _excludedMeshes;
  9886. /**
  9887. * Gets the meshes not impacted by this light.
  9888. */
  9889. /**
  9890. * Sets the meshes not impacted by this light.
  9891. */
  9892. excludedMeshes: AbstractMesh[];
  9893. private _excludeWithLayerMask;
  9894. /**
  9895. * Gets the layer id use to find what meshes are not impacted by the light.
  9896. * Inactive if 0
  9897. */
  9898. /**
  9899. * Sets the layer id use to find what meshes are not impacted by the light.
  9900. * Inactive if 0
  9901. */
  9902. excludeWithLayerMask: number;
  9903. private _includeOnlyWithLayerMask;
  9904. /**
  9905. * Gets the layer id use to find what meshes are impacted by the light.
  9906. * Inactive if 0
  9907. */
  9908. /**
  9909. * Sets the layer id use to find what meshes are impacted by the light.
  9910. * Inactive if 0
  9911. */
  9912. includeOnlyWithLayerMask: number;
  9913. private _lightmapMode;
  9914. /**
  9915. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9916. */
  9917. /**
  9918. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9919. */
  9920. lightmapMode: number;
  9921. /**
  9922. * Shadow generator associted to the light.
  9923. * @hidden Internal use only.
  9924. */
  9925. _shadowGenerator: Nullable<IShadowGenerator>;
  9926. /**
  9927. * @hidden Internal use only.
  9928. */
  9929. _excludedMeshesIds: string[];
  9930. /**
  9931. * @hidden Internal use only.
  9932. */
  9933. _includedOnlyMeshesIds: string[];
  9934. /**
  9935. * The current light unifom buffer.
  9936. * @hidden Internal use only.
  9937. */
  9938. _uniformBuffer: UniformBuffer;
  9939. /**
  9940. * Creates a Light object in the scene.
  9941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9942. * @param name The firendly name of the light
  9943. * @param scene The scene the light belongs too
  9944. */
  9945. constructor(name: string, scene: Scene);
  9946. protected abstract _buildUniformLayout(): void;
  9947. /**
  9948. * Sets the passed Effect "effect" with the Light information.
  9949. * @param effect The effect to update
  9950. * @param lightIndex The index of the light in the effect to update
  9951. * @returns The light
  9952. */
  9953. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9954. /**
  9955. * Sets the passed Effect "effect" with the Light information.
  9956. * @param effect The effect to update
  9957. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9958. * @returns The light
  9959. */
  9960. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9961. /**
  9962. * Returns the string "Light".
  9963. * @returns the class name
  9964. */
  9965. getClassName(): string;
  9966. /** @hidden */
  9967. readonly _isLight: boolean;
  9968. /**
  9969. * Converts the light information to a readable string for debug purpose.
  9970. * @param fullDetails Supports for multiple levels of logging within scene loading
  9971. * @returns the human readable light info
  9972. */
  9973. toString(fullDetails?: boolean): string;
  9974. /** @hidden */
  9975. protected _syncParentEnabledState(): void;
  9976. /**
  9977. * Set the enabled state of this node.
  9978. * @param value - the new enabled state
  9979. */
  9980. setEnabled(value: boolean): void;
  9981. /**
  9982. * Returns the Light associated shadow generator if any.
  9983. * @return the associated shadow generator.
  9984. */
  9985. getShadowGenerator(): Nullable<IShadowGenerator>;
  9986. /**
  9987. * Returns a Vector3, the absolute light position in the World.
  9988. * @returns the world space position of the light
  9989. */
  9990. getAbsolutePosition(): Vector3;
  9991. /**
  9992. * Specifies if the light will affect the passed mesh.
  9993. * @param mesh The mesh to test against the light
  9994. * @return true the mesh is affected otherwise, false.
  9995. */
  9996. canAffectMesh(mesh: AbstractMesh): boolean;
  9997. /**
  9998. * Sort function to order lights for rendering.
  9999. * @param a First Light object to compare to second.
  10000. * @param b Second Light object to compare first.
  10001. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10002. */
  10003. static CompareLightsPriority(a: Light, b: Light): number;
  10004. /**
  10005. * Releases resources associated with this node.
  10006. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10007. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10008. */
  10009. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10010. /**
  10011. * Returns the light type ID (integer).
  10012. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10013. */
  10014. getTypeID(): number;
  10015. /**
  10016. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10017. * @returns the scaled intensity in intensity mode unit
  10018. */
  10019. getScaledIntensity(): number;
  10020. /**
  10021. * Returns a new Light object, named "name", from the current one.
  10022. * @param name The name of the cloned light
  10023. * @returns the new created light
  10024. */
  10025. clone(name: string): Nullable<Light>;
  10026. /**
  10027. * Serializes the current light into a Serialization object.
  10028. * @returns the serialized object.
  10029. */
  10030. serialize(): any;
  10031. /**
  10032. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10033. * This new light is named "name" and added to the passed scene.
  10034. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10035. * @param name The friendly name of the light
  10036. * @param scene The scene the new light will belong to
  10037. * @returns the constructor function
  10038. */
  10039. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10040. /**
  10041. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10042. * @param parsedLight The JSON representation of the light
  10043. * @param scene The scene to create the parsed light in
  10044. * @returns the created light after parsing
  10045. */
  10046. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10047. private _hookArrayForExcluded;
  10048. private _hookArrayForIncludedOnly;
  10049. private _resyncMeshes;
  10050. /**
  10051. * Forces the meshes to update their light related information in their rendering used effects
  10052. * @hidden Internal Use Only
  10053. */
  10054. _markMeshesAsLightDirty(): void;
  10055. /**
  10056. * Recomputes the cached photometric scale if needed.
  10057. */
  10058. private _computePhotometricScale;
  10059. /**
  10060. * Returns the Photometric Scale according to the light type and intensity mode.
  10061. */
  10062. private _getPhotometricScale;
  10063. /**
  10064. * Reorder the light in the scene according to their defined priority.
  10065. * @hidden Internal Use Only
  10066. */
  10067. _reorderLightsInScene(): void;
  10068. /**
  10069. * Prepares the list of defines specific to the light type.
  10070. * @param defines the list of defines
  10071. * @param lightIndex defines the index of the light for the effect
  10072. */
  10073. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10074. }
  10075. }
  10076. declare module BABYLON {
  10077. /**
  10078. * Interface used to define Action
  10079. */
  10080. export interface IAction {
  10081. /**
  10082. * Trigger for the action
  10083. */
  10084. trigger: number;
  10085. /** Options of the trigger */
  10086. triggerOptions: any;
  10087. /**
  10088. * Gets the trigger parameters
  10089. * @returns the trigger parameters
  10090. */
  10091. getTriggerParameter(): any;
  10092. /**
  10093. * Internal only - executes current action event
  10094. * @hidden
  10095. */
  10096. _executeCurrent(evt?: ActionEvent): void;
  10097. /**
  10098. * Serialize placeholder for child classes
  10099. * @param parent of child
  10100. * @returns the serialized object
  10101. */
  10102. serialize(parent: any): any;
  10103. /**
  10104. * Internal only
  10105. * @hidden
  10106. */
  10107. _prepare(): void;
  10108. /**
  10109. * Internal only - manager for action
  10110. * @hidden
  10111. */
  10112. _actionManager: AbstractActionManager;
  10113. /**
  10114. * Adds action to chain of actions, may be a DoNothingAction
  10115. * @param action defines the next action to execute
  10116. * @returns The action passed in
  10117. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10118. */
  10119. then(action: IAction): IAction;
  10120. }
  10121. /**
  10122. * The action to be carried out following a trigger
  10123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10124. */
  10125. export class Action implements IAction {
  10126. /** the trigger, with or without parameters, for the action */
  10127. triggerOptions: any;
  10128. /**
  10129. * Trigger for the action
  10130. */
  10131. trigger: number;
  10132. /**
  10133. * Internal only - manager for action
  10134. * @hidden
  10135. */
  10136. _actionManager: ActionManager;
  10137. private _nextActiveAction;
  10138. private _child;
  10139. private _condition?;
  10140. private _triggerParameter;
  10141. /**
  10142. * An event triggered prior to action being executed.
  10143. */
  10144. onBeforeExecuteObservable: Observable<Action>;
  10145. /**
  10146. * Creates a new Action
  10147. * @param triggerOptions the trigger, with or without parameters, for the action
  10148. * @param condition an optional determinant of action
  10149. */
  10150. constructor(
  10151. /** the trigger, with or without parameters, for the action */
  10152. triggerOptions: any, condition?: Condition);
  10153. /**
  10154. * Internal only
  10155. * @hidden
  10156. */
  10157. _prepare(): void;
  10158. /**
  10159. * Gets the trigger parameters
  10160. * @returns the trigger parameters
  10161. */
  10162. getTriggerParameter(): any;
  10163. /**
  10164. * Internal only - executes current action event
  10165. * @hidden
  10166. */
  10167. _executeCurrent(evt?: ActionEvent): void;
  10168. /**
  10169. * Execute placeholder for child classes
  10170. * @param evt optional action event
  10171. */
  10172. execute(evt?: ActionEvent): void;
  10173. /**
  10174. * Skips to next active action
  10175. */
  10176. skipToNextActiveAction(): void;
  10177. /**
  10178. * Adds action to chain of actions, may be a DoNothingAction
  10179. * @param action defines the next action to execute
  10180. * @returns The action passed in
  10181. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10182. */
  10183. then(action: Action): Action;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. _getProperty(propertyPath: string): string;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. _getEffectiveTarget(target: any, propertyPath: string): any;
  10194. /**
  10195. * Serialize placeholder for child classes
  10196. * @param parent of child
  10197. * @returns the serialized object
  10198. */
  10199. serialize(parent: any): any;
  10200. /**
  10201. * Internal only called by serialize
  10202. * @hidden
  10203. */
  10204. protected _serialize(serializedAction: any, parent?: any): any;
  10205. /**
  10206. * Internal only
  10207. * @hidden
  10208. */
  10209. static _SerializeValueAsString: (value: any) => string;
  10210. /**
  10211. * Internal only
  10212. * @hidden
  10213. */
  10214. static _GetTargetProperty: (target: Node | Scene) => {
  10215. name: string;
  10216. targetType: string;
  10217. value: string;
  10218. };
  10219. }
  10220. }
  10221. declare module BABYLON {
  10222. /**
  10223. * A Condition applied to an Action
  10224. */
  10225. export class Condition {
  10226. /**
  10227. * Internal only - manager for action
  10228. * @hidden
  10229. */
  10230. _actionManager: ActionManager;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. _evaluationId: number;
  10236. /**
  10237. * Internal only
  10238. * @hidden
  10239. */
  10240. _currentResult: boolean;
  10241. /**
  10242. * Creates a new Condition
  10243. * @param actionManager the manager of the action the condition is applied to
  10244. */
  10245. constructor(actionManager: ActionManager);
  10246. /**
  10247. * Check if the current condition is valid
  10248. * @returns a boolean
  10249. */
  10250. isValid(): boolean;
  10251. /**
  10252. * Internal only
  10253. * @hidden
  10254. */
  10255. _getProperty(propertyPath: string): string;
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */
  10260. _getEffectiveTarget(target: any, propertyPath: string): any;
  10261. /**
  10262. * Serialize placeholder for child classes
  10263. * @returns the serialized object
  10264. */
  10265. serialize(): any;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. protected _serialize(serializedCondition: any): any;
  10271. }
  10272. /**
  10273. * Defines specific conditional operators as extensions of Condition
  10274. */
  10275. export class ValueCondition extends Condition {
  10276. /** path to specify the property of the target the conditional operator uses */
  10277. propertyPath: string;
  10278. /** the value compared by the conditional operator against the current value of the property */
  10279. value: any;
  10280. /** the conditional operator, default ValueCondition.IsEqual */
  10281. operator: number;
  10282. /**
  10283. * Internal only
  10284. * @hidden
  10285. */
  10286. private static _IsEqual;
  10287. /**
  10288. * Internal only
  10289. * @hidden
  10290. */
  10291. private static _IsDifferent;
  10292. /**
  10293. * Internal only
  10294. * @hidden
  10295. */
  10296. private static _IsGreater;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private static _IsLesser;
  10302. /**
  10303. * returns the number for IsEqual
  10304. */
  10305. static readonly IsEqual: number;
  10306. /**
  10307. * Returns the number for IsDifferent
  10308. */
  10309. static readonly IsDifferent: number;
  10310. /**
  10311. * Returns the number for IsGreater
  10312. */
  10313. static readonly IsGreater: number;
  10314. /**
  10315. * Returns the number for IsLesser
  10316. */
  10317. static readonly IsLesser: number;
  10318. /**
  10319. * Internal only The action manager for the condition
  10320. * @hidden
  10321. */
  10322. _actionManager: ActionManager;
  10323. /**
  10324. * Internal only
  10325. * @hidden
  10326. */
  10327. private _target;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. private _effectiveTarget;
  10333. /**
  10334. * Internal only
  10335. * @hidden
  10336. */
  10337. private _property;
  10338. /**
  10339. * Creates a new ValueCondition
  10340. * @param actionManager manager for the action the condition applies to
  10341. * @param target for the action
  10342. * @param propertyPath path to specify the property of the target the conditional operator uses
  10343. * @param value the value compared by the conditional operator against the current value of the property
  10344. * @param operator the conditional operator, default ValueCondition.IsEqual
  10345. */
  10346. constructor(actionManager: ActionManager, target: any,
  10347. /** path to specify the property of the target the conditional operator uses */
  10348. propertyPath: string,
  10349. /** the value compared by the conditional operator against the current value of the property */
  10350. value: any,
  10351. /** the conditional operator, default ValueCondition.IsEqual */
  10352. operator?: number);
  10353. /**
  10354. * Compares the given value with the property value for the specified conditional operator
  10355. * @returns the result of the comparison
  10356. */
  10357. isValid(): boolean;
  10358. /**
  10359. * Serialize the ValueCondition into a JSON compatible object
  10360. * @returns serialization object
  10361. */
  10362. serialize(): any;
  10363. /**
  10364. * Gets the name of the conditional operator for the ValueCondition
  10365. * @param operator the conditional operator
  10366. * @returns the name
  10367. */
  10368. static GetOperatorName(operator: number): string;
  10369. }
  10370. /**
  10371. * Defines a predicate condition as an extension of Condition
  10372. */
  10373. export class PredicateCondition extends Condition {
  10374. /** defines the predicate function used to validate the condition */
  10375. predicate: () => boolean;
  10376. /**
  10377. * Internal only - manager for action
  10378. * @hidden
  10379. */
  10380. _actionManager: ActionManager;
  10381. /**
  10382. * Creates a new PredicateCondition
  10383. * @param actionManager manager for the action the condition applies to
  10384. * @param predicate defines the predicate function used to validate the condition
  10385. */
  10386. constructor(actionManager: ActionManager,
  10387. /** defines the predicate function used to validate the condition */
  10388. predicate: () => boolean);
  10389. /**
  10390. * @returns the validity of the predicate condition
  10391. */
  10392. isValid(): boolean;
  10393. }
  10394. /**
  10395. * Defines a state condition as an extension of Condition
  10396. */
  10397. export class StateCondition extends Condition {
  10398. /** Value to compare with target state */
  10399. value: string;
  10400. /**
  10401. * Internal only - manager for action
  10402. * @hidden
  10403. */
  10404. _actionManager: ActionManager;
  10405. /**
  10406. * Internal only
  10407. * @hidden
  10408. */
  10409. private _target;
  10410. /**
  10411. * Creates a new StateCondition
  10412. * @param actionManager manager for the action the condition applies to
  10413. * @param target of the condition
  10414. * @param value to compare with target state
  10415. */
  10416. constructor(actionManager: ActionManager, target: any,
  10417. /** Value to compare with target state */
  10418. value: string);
  10419. /**
  10420. * Gets a boolean indicating if the current condition is met
  10421. * @returns the validity of the state
  10422. */
  10423. isValid(): boolean;
  10424. /**
  10425. * Serialize the StateCondition into a JSON compatible object
  10426. * @returns serialization object
  10427. */
  10428. serialize(): any;
  10429. }
  10430. }
  10431. declare module BABYLON {
  10432. /**
  10433. * This defines an action responsible to toggle a boolean once triggered.
  10434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10435. */
  10436. export class SwitchBooleanAction extends Action {
  10437. /**
  10438. * The path to the boolean property in the target object
  10439. */
  10440. propertyPath: string;
  10441. private _target;
  10442. private _effectiveTarget;
  10443. private _property;
  10444. /**
  10445. * Instantiate the action
  10446. * @param triggerOptions defines the trigger options
  10447. * @param target defines the object containing the boolean
  10448. * @param propertyPath defines the path to the boolean property in the target object
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10452. /** @hidden */
  10453. _prepare(): void;
  10454. /**
  10455. * Execute the action toggle the boolean value.
  10456. */
  10457. execute(): void;
  10458. /**
  10459. * Serializes the actions and its related information.
  10460. * @param parent defines the object to serialize in
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. }
  10465. /**
  10466. * This defines an action responsible to set a the state field of the target
  10467. * to a desired value once triggered.
  10468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10469. */
  10470. export class SetStateAction extends Action {
  10471. /**
  10472. * The value to store in the state field.
  10473. */
  10474. value: string;
  10475. private _target;
  10476. /**
  10477. * Instantiate the action
  10478. * @param triggerOptions defines the trigger options
  10479. * @param target defines the object containing the state property
  10480. * @param value defines the value to store in the state field
  10481. * @param condition defines the trigger related conditions
  10482. */
  10483. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10484. /**
  10485. * Execute the action and store the value on the target state property.
  10486. */
  10487. execute(): void;
  10488. /**
  10489. * Serializes the actions and its related information.
  10490. * @param parent defines the object to serialize in
  10491. * @returns the serialized object
  10492. */
  10493. serialize(parent: any): any;
  10494. }
  10495. /**
  10496. * This defines an action responsible to set a property of the target
  10497. * to a desired value once triggered.
  10498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10499. */
  10500. export class SetValueAction extends Action {
  10501. /**
  10502. * The path of the property to set in the target.
  10503. */
  10504. propertyPath: string;
  10505. /**
  10506. * The value to set in the property
  10507. */
  10508. value: any;
  10509. private _target;
  10510. private _effectiveTarget;
  10511. private _property;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the object containing the property
  10516. * @param propertyPath defines the path of the property to set in the target
  10517. * @param value defines the value to set in the property
  10518. * @param condition defines the trigger related conditions
  10519. */
  10520. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10521. /** @hidden */
  10522. _prepare(): void;
  10523. /**
  10524. * Execute the action and set the targetted property to the desired value.
  10525. */
  10526. execute(): void;
  10527. /**
  10528. * Serializes the actions and its related information.
  10529. * @param parent defines the object to serialize in
  10530. * @returns the serialized object
  10531. */
  10532. serialize(parent: any): any;
  10533. }
  10534. /**
  10535. * This defines an action responsible to increment the target value
  10536. * to a desired value once triggered.
  10537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10538. */
  10539. export class IncrementValueAction extends Action {
  10540. /**
  10541. * The path of the property to increment in the target.
  10542. */
  10543. propertyPath: string;
  10544. /**
  10545. * The value we should increment the property by.
  10546. */
  10547. value: any;
  10548. private _target;
  10549. private _effectiveTarget;
  10550. private _property;
  10551. /**
  10552. * Instantiate the action
  10553. * @param triggerOptions defines the trigger options
  10554. * @param target defines the object containing the property
  10555. * @param propertyPath defines the path of the property to increment in the target
  10556. * @param value defines the value value we should increment the property by
  10557. * @param condition defines the trigger related conditions
  10558. */
  10559. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10560. /** @hidden */
  10561. _prepare(): void;
  10562. /**
  10563. * Execute the action and increment the target of the value amount.
  10564. */
  10565. execute(): void;
  10566. /**
  10567. * Serializes the actions and its related information.
  10568. * @param parent defines the object to serialize in
  10569. * @returns the serialized object
  10570. */
  10571. serialize(parent: any): any;
  10572. }
  10573. /**
  10574. * This defines an action responsible to start an animation once triggered.
  10575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10576. */
  10577. export class PlayAnimationAction extends Action {
  10578. /**
  10579. * Where the animation should start (animation frame)
  10580. */
  10581. from: number;
  10582. /**
  10583. * Where the animation should stop (animation frame)
  10584. */
  10585. to: number;
  10586. /**
  10587. * Define if the animation should loop or stop after the first play.
  10588. */
  10589. loop?: boolean;
  10590. private _target;
  10591. /**
  10592. * Instantiate the action
  10593. * @param triggerOptions defines the trigger options
  10594. * @param target defines the target animation or animation name
  10595. * @param from defines from where the animation should start (animation frame)
  10596. * @param end defines where the animation should stop (animation frame)
  10597. * @param loop defines if the animation should loop or stop after the first play
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and play the animation.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to stop an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class StopAnimationAction extends Action {
  10619. private _target;
  10620. /**
  10621. * Instantiate the action
  10622. * @param triggerOptions defines the trigger options
  10623. * @param target defines the target animation or animation name
  10624. * @param condition defines the trigger related conditions
  10625. */
  10626. constructor(triggerOptions: any, target: any, condition?: Condition);
  10627. /** @hidden */
  10628. _prepare(): void;
  10629. /**
  10630. * Execute the action and stop the animation.
  10631. */
  10632. execute(): void;
  10633. /**
  10634. * Serializes the actions and its related information.
  10635. * @param parent defines the object to serialize in
  10636. * @returns the serialized object
  10637. */
  10638. serialize(parent: any): any;
  10639. }
  10640. /**
  10641. * This defines an action responsible that does nothing once triggered.
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10643. */
  10644. export class DoNothingAction extends Action {
  10645. /**
  10646. * Instantiate the action
  10647. * @param triggerOptions defines the trigger options
  10648. * @param condition defines the trigger related conditions
  10649. */
  10650. constructor(triggerOptions?: any, condition?: Condition);
  10651. /**
  10652. * Execute the action and do nothing.
  10653. */
  10654. execute(): void;
  10655. /**
  10656. * Serializes the actions and its related information.
  10657. * @param parent defines the object to serialize in
  10658. * @returns the serialized object
  10659. */
  10660. serialize(parent: any): any;
  10661. }
  10662. /**
  10663. * This defines an action responsible to trigger several actions once triggered.
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10665. */
  10666. export class CombineAction extends Action {
  10667. /**
  10668. * The list of aggregated animations to run.
  10669. */
  10670. children: Action[];
  10671. /**
  10672. * Instantiate the action
  10673. * @param triggerOptions defines the trigger options
  10674. * @param children defines the list of aggregated animations to run
  10675. * @param condition defines the trigger related conditions
  10676. */
  10677. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10678. /** @hidden */
  10679. _prepare(): void;
  10680. /**
  10681. * Execute the action and executes all the aggregated actions.
  10682. */
  10683. execute(evt: ActionEvent): void;
  10684. /**
  10685. * Serializes the actions and its related information.
  10686. * @param parent defines the object to serialize in
  10687. * @returns the serialized object
  10688. */
  10689. serialize(parent: any): any;
  10690. }
  10691. /**
  10692. * This defines an action responsible to run code (external event) once triggered.
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10694. */
  10695. export class ExecuteCodeAction extends Action {
  10696. /**
  10697. * The callback function to run.
  10698. */
  10699. func: (evt: ActionEvent) => void;
  10700. /**
  10701. * Instantiate the action
  10702. * @param triggerOptions defines the trigger options
  10703. * @param func defines the callback function to run
  10704. * @param condition defines the trigger related conditions
  10705. */
  10706. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10707. /**
  10708. * Execute the action and run the attached code.
  10709. */
  10710. execute(evt: ActionEvent): void;
  10711. }
  10712. /**
  10713. * This defines an action responsible to set the parent property of the target once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class SetParentAction extends Action {
  10717. private _parent;
  10718. private _target;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the target containing the parent property
  10723. * @param parent defines from where the animation should start (animation frame)
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10727. /** @hidden */
  10728. _prepare(): void;
  10729. /**
  10730. * Execute the action and set the parent property.
  10731. */
  10732. execute(): void;
  10733. /**
  10734. * Serializes the actions and its related information.
  10735. * @param parent defines the object to serialize in
  10736. * @returns the serialized object
  10737. */
  10738. serialize(parent: any): any;
  10739. }
  10740. }
  10741. declare module BABYLON {
  10742. /**
  10743. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10744. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10746. */
  10747. export class ActionManager extends AbstractActionManager {
  10748. /**
  10749. * Nothing
  10750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly NothingTrigger: number;
  10753. /**
  10754. * On pick
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnPickTrigger: number;
  10758. /**
  10759. * On left pick
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10761. */
  10762. static readonly OnLeftPickTrigger: number;
  10763. /**
  10764. * On right pick
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnRightPickTrigger: number;
  10768. /**
  10769. * On center pick
  10770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10771. */
  10772. static readonly OnCenterPickTrigger: number;
  10773. /**
  10774. * On pick down
  10775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10776. */
  10777. static readonly OnPickDownTrigger: number;
  10778. /**
  10779. * On double pick
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10781. */
  10782. static readonly OnDoublePickTrigger: number;
  10783. /**
  10784. * On pick up
  10785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10786. */
  10787. static readonly OnPickUpTrigger: number;
  10788. /**
  10789. * On pick out.
  10790. * This trigger will only be raised if you also declared a OnPickDown
  10791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10792. */
  10793. static readonly OnPickOutTrigger: number;
  10794. /**
  10795. * On long press
  10796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10797. */
  10798. static readonly OnLongPressTrigger: number;
  10799. /**
  10800. * On pointer over
  10801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10802. */
  10803. static readonly OnPointerOverTrigger: number;
  10804. /**
  10805. * On pointer out
  10806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10807. */
  10808. static readonly OnPointerOutTrigger: number;
  10809. /**
  10810. * On every frame
  10811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10812. */
  10813. static readonly OnEveryFrameTrigger: number;
  10814. /**
  10815. * On intersection enter
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10817. */
  10818. static readonly OnIntersectionEnterTrigger: number;
  10819. /**
  10820. * On intersection exit
  10821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10822. */
  10823. static readonly OnIntersectionExitTrigger: number;
  10824. /**
  10825. * On key down
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10827. */
  10828. static readonly OnKeyDownTrigger: number;
  10829. /**
  10830. * On key up
  10831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10832. */
  10833. static readonly OnKeyUpTrigger: number;
  10834. private _scene;
  10835. /**
  10836. * Creates a new action manager
  10837. * @param scene defines the hosting scene
  10838. */
  10839. constructor(scene: Scene);
  10840. /**
  10841. * Releases all associated resources
  10842. */
  10843. dispose(): void;
  10844. /**
  10845. * Gets hosting scene
  10846. * @returns the hosting scene
  10847. */
  10848. getScene(): Scene;
  10849. /**
  10850. * Does this action manager handles actions of any of the given triggers
  10851. * @param triggers defines the triggers to be tested
  10852. * @return a boolean indicating whether one (or more) of the triggers is handled
  10853. */
  10854. hasSpecificTriggers(triggers: number[]): boolean;
  10855. /**
  10856. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10857. * speed.
  10858. * @param triggerA defines the trigger to be tested
  10859. * @param triggerB defines the trigger to be tested
  10860. * @return a boolean indicating whether one (or more) of the triggers is handled
  10861. */
  10862. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10863. /**
  10864. * Does this action manager handles actions of a given trigger
  10865. * @param trigger defines the trigger to be tested
  10866. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10867. * @return whether the trigger is handled
  10868. */
  10869. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10870. /**
  10871. * Does this action manager has pointer triggers
  10872. */
  10873. readonly hasPointerTriggers: boolean;
  10874. /**
  10875. * Does this action manager has pick triggers
  10876. */
  10877. readonly hasPickTriggers: boolean;
  10878. /**
  10879. * Registers an action to this action manager
  10880. * @param action defines the action to be registered
  10881. * @return the action amended (prepared) after registration
  10882. */
  10883. registerAction(action: IAction): Nullable<IAction>;
  10884. /**
  10885. * Unregisters an action to this action manager
  10886. * @param action defines the action to be unregistered
  10887. * @return a boolean indicating whether the action has been unregistered
  10888. */
  10889. unregisterAction(action: IAction): Boolean;
  10890. /**
  10891. * Process a specific trigger
  10892. * @param trigger defines the trigger to process
  10893. * @param evt defines the event details to be processed
  10894. */
  10895. processTrigger(trigger: number, evt?: IActionEvent): void;
  10896. /** @hidden */
  10897. _getEffectiveTarget(target: any, propertyPath: string): any;
  10898. /** @hidden */
  10899. _getProperty(propertyPath: string): string;
  10900. /**
  10901. * Serialize this manager to a JSON object
  10902. * @param name defines the property name to store this manager
  10903. * @returns a JSON representation of this manager
  10904. */
  10905. serialize(name: string): any;
  10906. /**
  10907. * Creates a new ActionManager from a JSON data
  10908. * @param parsedActions defines the JSON data to read from
  10909. * @param object defines the hosting mesh
  10910. * @param scene defines the hosting scene
  10911. */
  10912. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10913. /**
  10914. * Get a trigger name by index
  10915. * @param trigger defines the trigger index
  10916. * @returns a trigger name
  10917. */
  10918. static GetTriggerName(trigger: number): string;
  10919. }
  10920. }
  10921. declare module BABYLON {
  10922. /**
  10923. * Class representing a ray with position and direction
  10924. */
  10925. export class Ray {
  10926. /** origin point */
  10927. origin: Vector3;
  10928. /** direction */
  10929. direction: Vector3;
  10930. /** length of the ray */
  10931. length: number;
  10932. private static readonly TmpVector3;
  10933. private _tmpRay;
  10934. /**
  10935. * Creates a new ray
  10936. * @param origin origin point
  10937. * @param direction direction
  10938. * @param length length of the ray
  10939. */
  10940. constructor(
  10941. /** origin point */
  10942. origin: Vector3,
  10943. /** direction */
  10944. direction: Vector3,
  10945. /** length of the ray */
  10946. length?: number);
  10947. /**
  10948. * Checks if the ray intersects a box
  10949. * @param minimum bound of the box
  10950. * @param maximum bound of the box
  10951. * @param intersectionTreshold extra extend to be added to the box in all direction
  10952. * @returns if the box was hit
  10953. */
  10954. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10955. /**
  10956. * Checks if the ray intersects a box
  10957. * @param box the bounding box to check
  10958. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10959. * @returns if the box was hit
  10960. */
  10961. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10962. /**
  10963. * If the ray hits a sphere
  10964. * @param sphere the bounding sphere to check
  10965. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10966. * @returns true if it hits the sphere
  10967. */
  10968. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10969. /**
  10970. * If the ray hits a triange
  10971. * @param vertex0 triangle vertex
  10972. * @param vertex1 triangle vertex
  10973. * @param vertex2 triangle vertex
  10974. * @returns intersection information if hit
  10975. */
  10976. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10977. /**
  10978. * Checks if ray intersects a plane
  10979. * @param plane the plane to check
  10980. * @returns the distance away it was hit
  10981. */
  10982. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10983. /**
  10984. * Calculate the intercept of a ray on a given axis
  10985. * @param axis to check 'x' | 'y' | 'z'
  10986. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10987. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10988. */
  10989. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10990. /**
  10991. * Checks if ray intersects a mesh
  10992. * @param mesh the mesh to check
  10993. * @param fastCheck if only the bounding box should checked
  10994. * @returns picking info of the intersecton
  10995. */
  10996. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10997. /**
  10998. * Checks if ray intersects a mesh
  10999. * @param meshes the meshes to check
  11000. * @param fastCheck if only the bounding box should checked
  11001. * @param results array to store result in
  11002. * @returns Array of picking infos
  11003. */
  11004. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11005. private _comparePickingInfo;
  11006. private static smallnum;
  11007. private static rayl;
  11008. /**
  11009. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11010. * @param sega the first point of the segment to test the intersection against
  11011. * @param segb the second point of the segment to test the intersection against
  11012. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11013. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11014. */
  11015. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11016. /**
  11017. * Update the ray from viewport position
  11018. * @param x position
  11019. * @param y y position
  11020. * @param viewportWidth viewport width
  11021. * @param viewportHeight viewport height
  11022. * @param world world matrix
  11023. * @param view view matrix
  11024. * @param projection projection matrix
  11025. * @returns this ray updated
  11026. */
  11027. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11028. /**
  11029. * Creates a ray with origin and direction of 0,0,0
  11030. * @returns the new ray
  11031. */
  11032. static Zero(): Ray;
  11033. /**
  11034. * Creates a new ray from screen space and viewport
  11035. * @param x position
  11036. * @param y y position
  11037. * @param viewportWidth viewport width
  11038. * @param viewportHeight viewport height
  11039. * @param world world matrix
  11040. * @param view view matrix
  11041. * @param projection projection matrix
  11042. * @returns new ray
  11043. */
  11044. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11045. /**
  11046. * 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
  11047. * transformed to the given world matrix.
  11048. * @param origin The origin point
  11049. * @param end The end point
  11050. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11051. * @returns the new ray
  11052. */
  11053. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11054. /**
  11055. * Transforms a ray by a matrix
  11056. * @param ray ray to transform
  11057. * @param matrix matrix to apply
  11058. * @returns the resulting new ray
  11059. */
  11060. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11061. /**
  11062. * Transforms a ray by a matrix
  11063. * @param ray ray to transform
  11064. * @param matrix matrix to apply
  11065. * @param result ray to store result in
  11066. */
  11067. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11068. /**
  11069. * Unproject a ray from screen space to object space
  11070. * @param sourceX defines the screen space x coordinate to use
  11071. * @param sourceY defines the screen space y coordinate to use
  11072. * @param viewportWidth defines the current width of the viewport
  11073. * @param viewportHeight defines the current height of the viewport
  11074. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11075. * @param view defines the view matrix to use
  11076. * @param projection defines the projection matrix to use
  11077. */
  11078. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11079. }
  11080. /**
  11081. * Type used to define predicate used to select faces when a mesh intersection is detected
  11082. */
  11083. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11084. interface Scene {
  11085. /** @hidden */
  11086. _tempPickingRay: Nullable<Ray>;
  11087. /** @hidden */
  11088. _cachedRayForTransform: Ray;
  11089. /** @hidden */
  11090. _pickWithRayInverseMatrix: Matrix;
  11091. /** @hidden */
  11092. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11093. /** @hidden */
  11094. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11095. }
  11096. }
  11097. declare module BABYLON {
  11098. /**
  11099. * Groups all the scene component constants in one place to ease maintenance.
  11100. * @hidden
  11101. */
  11102. export class SceneComponentConstants {
  11103. static readonly NAME_EFFECTLAYER: string;
  11104. static readonly NAME_LAYER: string;
  11105. static readonly NAME_LENSFLARESYSTEM: string;
  11106. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11107. static readonly NAME_PARTICLESYSTEM: string;
  11108. static readonly NAME_GAMEPAD: string;
  11109. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11110. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11111. static readonly NAME_DEPTHRENDERER: string;
  11112. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11113. static readonly NAME_SPRITE: string;
  11114. static readonly NAME_OUTLINERENDERER: string;
  11115. static readonly NAME_PROCEDURALTEXTURE: string;
  11116. static readonly NAME_SHADOWGENERATOR: string;
  11117. static readonly NAME_OCTREE: string;
  11118. static readonly NAME_PHYSICSENGINE: string;
  11119. static readonly NAME_AUDIO: string;
  11120. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11121. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11122. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11123. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11124. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11125. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11126. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11127. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11128. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11129. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11130. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11131. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11132. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11133. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11134. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11135. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11136. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11137. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11138. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11139. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11140. static readonly STEP_AFTERRENDER_AUDIO: number;
  11141. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11142. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11143. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11144. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11145. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11146. static readonly STEP_POINTERMOVE_SPRITE: number;
  11147. static readonly STEP_POINTERDOWN_SPRITE: number;
  11148. static readonly STEP_POINTERUP_SPRITE: number;
  11149. }
  11150. /**
  11151. * This represents a scene component.
  11152. *
  11153. * This is used to decouple the dependency the scene is having on the different workloads like
  11154. * layers, post processes...
  11155. */
  11156. export interface ISceneComponent {
  11157. /**
  11158. * The name of the component. Each component must have a unique name.
  11159. */
  11160. name: string;
  11161. /**
  11162. * The scene the component belongs to.
  11163. */
  11164. scene: Scene;
  11165. /**
  11166. * Register the component to one instance of a scene.
  11167. */
  11168. register(): void;
  11169. /**
  11170. * Rebuilds the elements related to this component in case of
  11171. * context lost for instance.
  11172. */
  11173. rebuild(): void;
  11174. /**
  11175. * Disposes the component and the associated ressources.
  11176. */
  11177. dispose(): void;
  11178. }
  11179. /**
  11180. * This represents a SERIALIZABLE scene component.
  11181. *
  11182. * This extends Scene Component to add Serialization methods on top.
  11183. */
  11184. export interface ISceneSerializableComponent extends ISceneComponent {
  11185. /**
  11186. * Adds all the elements from the container to the scene
  11187. * @param container the container holding the elements
  11188. */
  11189. addFromContainer(container: AbstractScene): void;
  11190. /**
  11191. * Removes all the elements in the container from the scene
  11192. * @param container contains the elements to remove
  11193. * @param dispose if the removed element should be disposed (default: false)
  11194. */
  11195. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11196. /**
  11197. * Serializes the component data to the specified json object
  11198. * @param serializationObject The object to serialize to
  11199. */
  11200. serialize(serializationObject: any): void;
  11201. }
  11202. /**
  11203. * Strong typing of a Mesh related stage step action
  11204. */
  11205. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11206. /**
  11207. * Strong typing of a Evaluate Sub Mesh related stage step action
  11208. */
  11209. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11210. /**
  11211. * Strong typing of a Active Mesh related stage step action
  11212. */
  11213. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11214. /**
  11215. * Strong typing of a Camera related stage step action
  11216. */
  11217. export type CameraStageAction = (camera: Camera) => void;
  11218. /**
  11219. * Strong typing of a Camera Frame buffer related stage step action
  11220. */
  11221. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11222. /**
  11223. * Strong typing of a Render Target related stage step action
  11224. */
  11225. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11226. /**
  11227. * Strong typing of a RenderingGroup related stage step action
  11228. */
  11229. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11230. /**
  11231. * Strong typing of a Mesh Render related stage step action
  11232. */
  11233. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11234. /**
  11235. * Strong typing of a simple stage step action
  11236. */
  11237. export type SimpleStageAction = () => void;
  11238. /**
  11239. * Strong typing of a render target action.
  11240. */
  11241. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11242. /**
  11243. * Strong typing of a pointer move action.
  11244. */
  11245. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11246. /**
  11247. * Strong typing of a pointer up/down action.
  11248. */
  11249. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11250. /**
  11251. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11252. * @hidden
  11253. */
  11254. export class Stage<T extends Function> extends Array<{
  11255. index: number;
  11256. component: ISceneComponent;
  11257. action: T;
  11258. }> {
  11259. /**
  11260. * Hide ctor from the rest of the world.
  11261. * @param items The items to add.
  11262. */
  11263. private constructor();
  11264. /**
  11265. * Creates a new Stage.
  11266. * @returns A new instance of a Stage
  11267. */
  11268. static Create<T extends Function>(): Stage<T>;
  11269. /**
  11270. * Registers a step in an ordered way in the targeted stage.
  11271. * @param index Defines the position to register the step in
  11272. * @param component Defines the component attached to the step
  11273. * @param action Defines the action to launch during the step
  11274. */
  11275. registerStep(index: number, component: ISceneComponent, action: T): void;
  11276. /**
  11277. * Clears all the steps from the stage.
  11278. */
  11279. clear(): void;
  11280. }
  11281. }
  11282. declare module BABYLON {
  11283. interface Scene {
  11284. /** @hidden */
  11285. _pointerOverSprite: Nullable<Sprite>;
  11286. /** @hidden */
  11287. _pickedDownSprite: Nullable<Sprite>;
  11288. /** @hidden */
  11289. _tempSpritePickingRay: Nullable<Ray>;
  11290. /**
  11291. * All of the sprite managers added to this scene
  11292. * @see http://doc.babylonjs.com/babylon101/sprites
  11293. */
  11294. spriteManagers: Array<ISpriteManager>;
  11295. /**
  11296. * An event triggered when sprites rendering is about to start
  11297. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11298. */
  11299. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11300. /**
  11301. * An event triggered when sprites rendering is done
  11302. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11303. */
  11304. onAfterSpritesRenderingObservable: Observable<Scene>;
  11305. /** @hidden */
  11306. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11307. /** Launch a ray to try to pick a sprite in the scene
  11308. * @param x position on screen
  11309. * @param y position on screen
  11310. * @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
  11311. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11312. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11313. * @returns a PickingInfo
  11314. */
  11315. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11316. /** Use the given ray to pick a sprite in the scene
  11317. * @param ray The ray (in world space) to use to pick meshes
  11318. * @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
  11319. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11320. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11321. * @returns a PickingInfo
  11322. */
  11323. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11324. /** @hidden */
  11325. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11326. /** Launch a ray to try to pick sprites in the scene
  11327. * @param x position on screen
  11328. * @param y position on screen
  11329. * @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
  11330. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11331. * @returns a PickingInfo array
  11332. */
  11333. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11334. /** Use the given ray to pick sprites in the scene
  11335. * @param ray The ray (in world space) to use to pick meshes
  11336. * @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
  11337. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11338. * @returns a PickingInfo array
  11339. */
  11340. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11341. /**
  11342. * Force the sprite under the pointer
  11343. * @param sprite defines the sprite to use
  11344. */
  11345. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11346. /**
  11347. * Gets the sprite under the pointer
  11348. * @returns a Sprite or null if no sprite is under the pointer
  11349. */
  11350. getPointerOverSprite(): Nullable<Sprite>;
  11351. }
  11352. /**
  11353. * Defines the sprite scene component responsible to manage sprites
  11354. * in a given scene.
  11355. */
  11356. export class SpriteSceneComponent implements ISceneComponent {
  11357. /**
  11358. * The component name helpfull to identify the component in the list of scene components.
  11359. */
  11360. readonly name: string;
  11361. /**
  11362. * The scene the component belongs to.
  11363. */
  11364. scene: Scene;
  11365. /** @hidden */
  11366. private _spritePredicate;
  11367. /**
  11368. * Creates a new instance of the component for the given scene
  11369. * @param scene Defines the scene to register the component in
  11370. */
  11371. constructor(scene: Scene);
  11372. /**
  11373. * Registers the component in a given scene
  11374. */
  11375. register(): void;
  11376. /**
  11377. * Rebuilds the elements related to this component in case of
  11378. * context lost for instance.
  11379. */
  11380. rebuild(): void;
  11381. /**
  11382. * Disposes the component and the associated ressources.
  11383. */
  11384. dispose(): void;
  11385. private _pickSpriteButKeepRay;
  11386. private _pointerMove;
  11387. private _pointerDown;
  11388. private _pointerUp;
  11389. }
  11390. }
  11391. declare module BABYLON {
  11392. /** @hidden */
  11393. export var fogFragmentDeclaration: {
  11394. name: string;
  11395. shader: string;
  11396. };
  11397. }
  11398. declare module BABYLON {
  11399. /** @hidden */
  11400. export var fogFragment: {
  11401. name: string;
  11402. shader: string;
  11403. };
  11404. }
  11405. declare module BABYLON {
  11406. /** @hidden */
  11407. export var spritesPixelShader: {
  11408. name: string;
  11409. shader: string;
  11410. };
  11411. }
  11412. declare module BABYLON {
  11413. /** @hidden */
  11414. export var fogVertexDeclaration: {
  11415. name: string;
  11416. shader: string;
  11417. };
  11418. }
  11419. declare module BABYLON {
  11420. /** @hidden */
  11421. export var spritesVertexShader: {
  11422. name: string;
  11423. shader: string;
  11424. };
  11425. }
  11426. declare module BABYLON {
  11427. /**
  11428. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11429. */
  11430. export interface ISpriteManager extends IDisposable {
  11431. /**
  11432. * Restricts the camera to viewing objects with the same layerMask.
  11433. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11434. */
  11435. layerMask: number;
  11436. /**
  11437. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11438. */
  11439. isPickable: boolean;
  11440. /**
  11441. * Specifies the rendering group id for this mesh (0 by default)
  11442. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11443. */
  11444. renderingGroupId: number;
  11445. /**
  11446. * Defines the list of sprites managed by the manager.
  11447. */
  11448. sprites: Array<Sprite>;
  11449. /**
  11450. * Tests the intersection of a sprite with a specific ray.
  11451. * @param ray The ray we are sending to test the collision
  11452. * @param camera The camera space we are sending rays in
  11453. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11454. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11455. * @returns picking info or null.
  11456. */
  11457. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11458. /**
  11459. * Intersects the sprites with a ray
  11460. * @param ray defines the ray to intersect with
  11461. * @param camera defines the current active camera
  11462. * @param predicate defines a predicate used to select candidate sprites
  11463. * @returns null if no hit or a PickingInfo array
  11464. */
  11465. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11466. /**
  11467. * Renders the list of sprites on screen.
  11468. */
  11469. render(): void;
  11470. }
  11471. /**
  11472. * Class used to manage multiple sprites on the same spritesheet
  11473. * @see http://doc.babylonjs.com/babylon101/sprites
  11474. */
  11475. export class SpriteManager implements ISpriteManager {
  11476. /** defines the manager's name */
  11477. name: string;
  11478. /** Gets the list of sprites */
  11479. sprites: Sprite[];
  11480. /** Gets or sets the rendering group id (0 by default) */
  11481. renderingGroupId: number;
  11482. /** Gets or sets camera layer mask */
  11483. layerMask: number;
  11484. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11485. fogEnabled: boolean;
  11486. /** Gets or sets a boolean indicating if the sprites are pickable */
  11487. isPickable: boolean;
  11488. /** Defines the default width of a cell in the spritesheet */
  11489. cellWidth: number;
  11490. /** Defines the default height of a cell in the spritesheet */
  11491. cellHeight: number;
  11492. /** Associative array from JSON sprite data file */
  11493. private _cellData;
  11494. /** Array of sprite names from JSON sprite data file */
  11495. private _spriteMap;
  11496. /** True when packed cell data from JSON file is ready*/
  11497. private _packedAndReady;
  11498. /**
  11499. * An event triggered when the manager is disposed.
  11500. */
  11501. onDisposeObservable: Observable<SpriteManager>;
  11502. private _onDisposeObserver;
  11503. /**
  11504. * Callback called when the manager is disposed
  11505. */
  11506. onDispose: () => void;
  11507. private _capacity;
  11508. private _fromPacked;
  11509. private _spriteTexture;
  11510. private _epsilon;
  11511. private _scene;
  11512. private _vertexData;
  11513. private _buffer;
  11514. private _vertexBuffers;
  11515. private _indexBuffer;
  11516. private _effectBase;
  11517. private _effectFog;
  11518. /**
  11519. * Gets or sets the spritesheet texture
  11520. */
  11521. texture: Texture;
  11522. /**
  11523. * Creates a new sprite manager
  11524. * @param name defines the manager's name
  11525. * @param imgUrl defines the sprite sheet url
  11526. * @param capacity defines the maximum allowed number of sprites
  11527. * @param cellSize defines the size of a sprite cell
  11528. * @param scene defines the hosting scene
  11529. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11530. * @param samplingMode defines the smapling mode to use with spritesheet
  11531. * @param fromPacked set to false; do not alter
  11532. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11533. */
  11534. constructor(
  11535. /** defines the manager's name */
  11536. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11537. private _makePacked;
  11538. private _appendSpriteVertex;
  11539. /**
  11540. * Intersects the sprites with a ray
  11541. * @param ray defines the ray to intersect with
  11542. * @param camera defines the current active camera
  11543. * @param predicate defines a predicate used to select candidate sprites
  11544. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11545. * @returns null if no hit or a PickingInfo
  11546. */
  11547. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11548. /**
  11549. * Intersects the sprites with a ray
  11550. * @param ray defines the ray to intersect with
  11551. * @param camera defines the current active camera
  11552. * @param predicate defines a predicate used to select candidate sprites
  11553. * @returns null if no hit or a PickingInfo array
  11554. */
  11555. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11556. /**
  11557. * Render all child sprites
  11558. */
  11559. render(): void;
  11560. /**
  11561. * Release associated resources
  11562. */
  11563. dispose(): void;
  11564. }
  11565. }
  11566. declare module BABYLON {
  11567. /**
  11568. * Class used to represent a sprite
  11569. * @see http://doc.babylonjs.com/babylon101/sprites
  11570. */
  11571. export class Sprite {
  11572. /** defines the name */
  11573. name: string;
  11574. /** Gets or sets the current world position */
  11575. position: Vector3;
  11576. /** Gets or sets the main color */
  11577. color: Color4;
  11578. /** Gets or sets the width */
  11579. width: number;
  11580. /** Gets or sets the height */
  11581. height: number;
  11582. /** Gets or sets rotation angle */
  11583. angle: number;
  11584. /** Gets or sets the cell index in the sprite sheet */
  11585. cellIndex: number;
  11586. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11587. cellRef: string;
  11588. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11589. invertU: number;
  11590. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11591. invertV: number;
  11592. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11593. disposeWhenFinishedAnimating: boolean;
  11594. /** Gets the list of attached animations */
  11595. animations: Animation[];
  11596. /** Gets or sets a boolean indicating if the sprite can be picked */
  11597. isPickable: boolean;
  11598. /**
  11599. * Gets or sets the associated action manager
  11600. */
  11601. actionManager: Nullable<ActionManager>;
  11602. private _animationStarted;
  11603. private _loopAnimation;
  11604. private _fromIndex;
  11605. private _toIndex;
  11606. private _delay;
  11607. private _direction;
  11608. private _manager;
  11609. private _time;
  11610. private _onAnimationEnd;
  11611. /**
  11612. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11613. */
  11614. isVisible: boolean;
  11615. /**
  11616. * Gets or sets the sprite size
  11617. */
  11618. size: number;
  11619. /**
  11620. * Creates a new Sprite
  11621. * @param name defines the name
  11622. * @param manager defines the manager
  11623. */
  11624. constructor(
  11625. /** defines the name */
  11626. name: string, manager: ISpriteManager);
  11627. /**
  11628. * Starts an animation
  11629. * @param from defines the initial key
  11630. * @param to defines the end key
  11631. * @param loop defines if the animation must loop
  11632. * @param delay defines the start delay (in ms)
  11633. * @param onAnimationEnd defines a callback to call when animation ends
  11634. */
  11635. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11636. /** Stops current animation (if any) */
  11637. stopAnimation(): void;
  11638. /** @hidden */
  11639. _animate(deltaTime: number): void;
  11640. /** Release associated resources */
  11641. dispose(): void;
  11642. }
  11643. }
  11644. declare module BABYLON {
  11645. /**
  11646. * Information about the result of picking within a scene
  11647. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11648. */
  11649. export class PickingInfo {
  11650. /** @hidden */
  11651. _pickingUnavailable: boolean;
  11652. /**
  11653. * If the pick collided with an object
  11654. */
  11655. hit: boolean;
  11656. /**
  11657. * Distance away where the pick collided
  11658. */
  11659. distance: number;
  11660. /**
  11661. * The location of pick collision
  11662. */
  11663. pickedPoint: Nullable<Vector3>;
  11664. /**
  11665. * The mesh corresponding the the pick collision
  11666. */
  11667. pickedMesh: Nullable<AbstractMesh>;
  11668. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11669. bu: number;
  11670. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11671. bv: number;
  11672. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11673. faceId: number;
  11674. /** Id of the the submesh that was picked */
  11675. subMeshId: number;
  11676. /** If a sprite was picked, this will be the sprite the pick collided with */
  11677. pickedSprite: Nullable<Sprite>;
  11678. /**
  11679. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11680. */
  11681. originMesh: Nullable<AbstractMesh>;
  11682. /**
  11683. * The ray that was used to perform the picking.
  11684. */
  11685. ray: Nullable<Ray>;
  11686. /**
  11687. * Gets the normal correspodning to the face the pick collided with
  11688. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11689. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11690. * @returns The normal correspodning to the face the pick collided with
  11691. */
  11692. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11693. /**
  11694. * Gets the texture coordinates of where the pick occured
  11695. * @returns the vector containing the coordnates of the texture
  11696. */
  11697. getTextureCoordinates(): Nullable<Vector2>;
  11698. }
  11699. }
  11700. declare module BABYLON {
  11701. /**
  11702. * Gather the list of pointer event types as constants.
  11703. */
  11704. export class PointerEventTypes {
  11705. /**
  11706. * 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.
  11707. */
  11708. static readonly POINTERDOWN: number;
  11709. /**
  11710. * The pointerup event is fired when a pointer is no longer active.
  11711. */
  11712. static readonly POINTERUP: number;
  11713. /**
  11714. * The pointermove event is fired when a pointer changes coordinates.
  11715. */
  11716. static readonly POINTERMOVE: number;
  11717. /**
  11718. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11719. */
  11720. static readonly POINTERWHEEL: number;
  11721. /**
  11722. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11723. */
  11724. static readonly POINTERPICK: number;
  11725. /**
  11726. * The pointertap event is fired when a the object has been touched and released without drag.
  11727. */
  11728. static readonly POINTERTAP: number;
  11729. /**
  11730. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11731. */
  11732. static readonly POINTERDOUBLETAP: number;
  11733. }
  11734. /**
  11735. * Base class of pointer info types.
  11736. */
  11737. export class PointerInfoBase {
  11738. /**
  11739. * Defines the type of event (PointerEventTypes)
  11740. */
  11741. type: number;
  11742. /**
  11743. * Defines the related dom event
  11744. */
  11745. event: PointerEvent | MouseWheelEvent;
  11746. /**
  11747. * Instantiates the base class of pointers info.
  11748. * @param type Defines the type of event (PointerEventTypes)
  11749. * @param event Defines the related dom event
  11750. */
  11751. constructor(
  11752. /**
  11753. * Defines the type of event (PointerEventTypes)
  11754. */
  11755. type: number,
  11756. /**
  11757. * Defines the related dom event
  11758. */
  11759. event: PointerEvent | MouseWheelEvent);
  11760. }
  11761. /**
  11762. * This class is used to store pointer related info for the onPrePointerObservable event.
  11763. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11764. */
  11765. export class PointerInfoPre extends PointerInfoBase {
  11766. /**
  11767. * Ray from a pointer if availible (eg. 6dof controller)
  11768. */
  11769. ray: Nullable<Ray>;
  11770. /**
  11771. * Defines the local position of the pointer on the canvas.
  11772. */
  11773. localPosition: Vector2;
  11774. /**
  11775. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11776. */
  11777. skipOnPointerObservable: boolean;
  11778. /**
  11779. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11780. * @param type Defines the type of event (PointerEventTypes)
  11781. * @param event Defines the related dom event
  11782. * @param localX Defines the local x coordinates of the pointer when the event occured
  11783. * @param localY Defines the local y coordinates of the pointer when the event occured
  11784. */
  11785. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11786. }
  11787. /**
  11788. * This type contains all the data related to a pointer event in Babylon.js.
  11789. * 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.
  11790. */
  11791. export class PointerInfo extends PointerInfoBase {
  11792. /**
  11793. * Defines the picking info associated to the info (if any)\
  11794. */
  11795. pickInfo: Nullable<PickingInfo>;
  11796. /**
  11797. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11798. * @param type Defines the type of event (PointerEventTypes)
  11799. * @param event Defines the related dom event
  11800. * @param pickInfo Defines the picking info associated to the info (if any)\
  11801. */
  11802. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11803. /**
  11804. * Defines the picking info associated to the info (if any)\
  11805. */
  11806. pickInfo: Nullable<PickingInfo>);
  11807. }
  11808. /**
  11809. * Data relating to a touch event on the screen.
  11810. */
  11811. export interface PointerTouch {
  11812. /**
  11813. * X coordinate of touch.
  11814. */
  11815. x: number;
  11816. /**
  11817. * Y coordinate of touch.
  11818. */
  11819. y: number;
  11820. /**
  11821. * Id of touch. Unique for each finger.
  11822. */
  11823. pointerId: number;
  11824. /**
  11825. * Event type passed from DOM.
  11826. */
  11827. type: any;
  11828. }
  11829. }
  11830. declare module BABYLON {
  11831. /**
  11832. * Manage the mouse inputs to control the movement of a free camera.
  11833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11834. */
  11835. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11836. /**
  11837. * Define if touch is enabled in the mouse input
  11838. */
  11839. touchEnabled: boolean;
  11840. /**
  11841. * Defines the camera the input is attached to.
  11842. */
  11843. camera: FreeCamera;
  11844. /**
  11845. * Defines the buttons associated with the input to handle camera move.
  11846. */
  11847. buttons: number[];
  11848. /**
  11849. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11850. */
  11851. angularSensibility: number;
  11852. private _pointerInput;
  11853. private _onMouseMove;
  11854. private _observer;
  11855. private previousPosition;
  11856. /**
  11857. * Observable for when a pointer move event occurs containing the move offset
  11858. */
  11859. onPointerMovedObservable: Observable<{
  11860. offsetX: number;
  11861. offsetY: number;
  11862. }>;
  11863. /**
  11864. * @hidden
  11865. * If the camera should be rotated automatically based on pointer movement
  11866. */
  11867. _allowCameraRotation: boolean;
  11868. /**
  11869. * Manage the mouse inputs to control the movement of a free camera.
  11870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11871. * @param touchEnabled Defines if touch is enabled or not
  11872. */
  11873. constructor(
  11874. /**
  11875. * Define if touch is enabled in the mouse input
  11876. */
  11877. touchEnabled?: boolean);
  11878. /**
  11879. * Attach the input controls to a specific dom element to get the input from.
  11880. * @param element Defines the element the controls should be listened from
  11881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11882. */
  11883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11884. /**
  11885. * Called on JS contextmenu event.
  11886. * Override this method to provide functionality.
  11887. */
  11888. protected onContextMenu(evt: PointerEvent): void;
  11889. /**
  11890. * Detach the current controls from the specified dom element.
  11891. * @param element Defines the element to stop listening the inputs from
  11892. */
  11893. detachControl(element: Nullable<HTMLElement>): void;
  11894. /**
  11895. * Gets the class name of the current intput.
  11896. * @returns the class name
  11897. */
  11898. getClassName(): string;
  11899. /**
  11900. * Get the friendly name associated with the input class.
  11901. * @returns the input friendly name
  11902. */
  11903. getSimpleName(): string;
  11904. }
  11905. }
  11906. declare module BABYLON {
  11907. /**
  11908. * Manage the touch inputs to control the movement of a free camera.
  11909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11910. */
  11911. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11912. /**
  11913. * Defines the camera the input is attached to.
  11914. */
  11915. camera: FreeCamera;
  11916. /**
  11917. * Defines the touch sensibility for rotation.
  11918. * The higher the faster.
  11919. */
  11920. touchAngularSensibility: number;
  11921. /**
  11922. * Defines the touch sensibility for move.
  11923. * The higher the faster.
  11924. */
  11925. touchMoveSensibility: number;
  11926. private _offsetX;
  11927. private _offsetY;
  11928. private _pointerPressed;
  11929. private _pointerInput;
  11930. private _observer;
  11931. private _onLostFocus;
  11932. /**
  11933. * Attach the input controls to a specific dom element to get the input from.
  11934. * @param element Defines the element the controls should be listened from
  11935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11936. */
  11937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11938. /**
  11939. * Detach the current controls from the specified dom element.
  11940. * @param element Defines the element to stop listening the inputs from
  11941. */
  11942. detachControl(element: Nullable<HTMLElement>): void;
  11943. /**
  11944. * Update the current camera state depending on the inputs that have been used this frame.
  11945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11946. */
  11947. checkInputs(): void;
  11948. /**
  11949. * Gets the class name of the current intput.
  11950. * @returns the class name
  11951. */
  11952. getClassName(): string;
  11953. /**
  11954. * Get the friendly name associated with the input class.
  11955. * @returns the input friendly name
  11956. */
  11957. getSimpleName(): string;
  11958. }
  11959. }
  11960. declare module BABYLON {
  11961. /**
  11962. * Default Inputs manager for the FreeCamera.
  11963. * It groups all the default supported inputs for ease of use.
  11964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11965. */
  11966. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11967. /**
  11968. * @hidden
  11969. */
  11970. _mouseInput: Nullable<FreeCameraMouseInput>;
  11971. /**
  11972. * Instantiates a new FreeCameraInputsManager.
  11973. * @param camera Defines the camera the inputs belong to
  11974. */
  11975. constructor(camera: FreeCamera);
  11976. /**
  11977. * Add keyboard input support to the input manager.
  11978. * @returns the current input manager
  11979. */
  11980. addKeyboard(): FreeCameraInputsManager;
  11981. /**
  11982. * Add mouse input support to the input manager.
  11983. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11984. * @returns the current input manager
  11985. */
  11986. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11987. /**
  11988. * Removes the mouse input support from the manager
  11989. * @returns the current input manager
  11990. */
  11991. removeMouse(): FreeCameraInputsManager;
  11992. /**
  11993. * Add touch input support to the input manager.
  11994. * @returns the current input manager
  11995. */
  11996. addTouch(): FreeCameraInputsManager;
  11997. /**
  11998. * Remove all attached input methods from a camera
  11999. */
  12000. clear(): void;
  12001. }
  12002. }
  12003. declare module BABYLON {
  12004. /**
  12005. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12006. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12007. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12008. */
  12009. export class FreeCamera extends TargetCamera {
  12010. /**
  12011. * Define the collision ellipsoid of the camera.
  12012. * This is helpful to simulate a camera body like the player body around the camera
  12013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12014. */
  12015. ellipsoid: Vector3;
  12016. /**
  12017. * Define an offset for the position of the ellipsoid around the camera.
  12018. * This can be helpful to determine the center of the body near the gravity center of the body
  12019. * instead of its head.
  12020. */
  12021. ellipsoidOffset: Vector3;
  12022. /**
  12023. * Enable or disable collisions of the camera with the rest of the scene objects.
  12024. */
  12025. checkCollisions: boolean;
  12026. /**
  12027. * Enable or disable gravity on the camera.
  12028. */
  12029. applyGravity: boolean;
  12030. /**
  12031. * Define the input manager associated to the camera.
  12032. */
  12033. inputs: FreeCameraInputsManager;
  12034. /**
  12035. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12036. * Higher values reduce sensitivity.
  12037. */
  12038. /**
  12039. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12040. * Higher values reduce sensitivity.
  12041. */
  12042. angularSensibility: number;
  12043. /**
  12044. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12045. */
  12046. keysUp: number[];
  12047. /**
  12048. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12049. */
  12050. keysDown: number[];
  12051. /**
  12052. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12053. */
  12054. keysLeft: number[];
  12055. /**
  12056. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12057. */
  12058. keysRight: number[];
  12059. /**
  12060. * Event raised when the camera collide with a mesh in the scene.
  12061. */
  12062. onCollide: (collidedMesh: AbstractMesh) => void;
  12063. private _collider;
  12064. private _needMoveForGravity;
  12065. private _oldPosition;
  12066. private _diffPosition;
  12067. private _newPosition;
  12068. /** @hidden */
  12069. _localDirection: Vector3;
  12070. /** @hidden */
  12071. _transformedDirection: Vector3;
  12072. /**
  12073. * Instantiates a Free Camera.
  12074. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12075. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12076. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12077. * @param name Define the name of the camera in the scene
  12078. * @param position Define the start position of the camera in the scene
  12079. * @param scene Define the scene the camera belongs to
  12080. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12081. */
  12082. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12083. /**
  12084. * Attached controls to the current camera.
  12085. * @param element Defines the element the controls should be listened from
  12086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12087. */
  12088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12089. /**
  12090. * Detach the current controls from the camera.
  12091. * The camera will stop reacting to inputs.
  12092. * @param element Defines the element to stop listening the inputs from
  12093. */
  12094. detachControl(element: HTMLElement): void;
  12095. private _collisionMask;
  12096. /**
  12097. * Define a collision mask to limit the list of object the camera can collide with
  12098. */
  12099. collisionMask: number;
  12100. /** @hidden */
  12101. _collideWithWorld(displacement: Vector3): void;
  12102. private _onCollisionPositionChange;
  12103. /** @hidden */
  12104. _checkInputs(): void;
  12105. /** @hidden */
  12106. _decideIfNeedsToMove(): boolean;
  12107. /** @hidden */
  12108. _updatePosition(): void;
  12109. /**
  12110. * Destroy the camera and release the current resources hold by it.
  12111. */
  12112. dispose(): void;
  12113. /**
  12114. * Gets the current object class name.
  12115. * @return the class name
  12116. */
  12117. getClassName(): string;
  12118. }
  12119. }
  12120. declare module BABYLON {
  12121. /**
  12122. * Represents a gamepad control stick position
  12123. */
  12124. export class StickValues {
  12125. /**
  12126. * The x component of the control stick
  12127. */
  12128. x: number;
  12129. /**
  12130. * The y component of the control stick
  12131. */
  12132. y: number;
  12133. /**
  12134. * Initializes the gamepad x and y control stick values
  12135. * @param x The x component of the gamepad control stick value
  12136. * @param y The y component of the gamepad control stick value
  12137. */
  12138. constructor(
  12139. /**
  12140. * The x component of the control stick
  12141. */
  12142. x: number,
  12143. /**
  12144. * The y component of the control stick
  12145. */
  12146. y: number);
  12147. }
  12148. /**
  12149. * An interface which manages callbacks for gamepad button changes
  12150. */
  12151. export interface GamepadButtonChanges {
  12152. /**
  12153. * Called when a gamepad has been changed
  12154. */
  12155. changed: boolean;
  12156. /**
  12157. * Called when a gamepad press event has been triggered
  12158. */
  12159. pressChanged: boolean;
  12160. /**
  12161. * Called when a touch event has been triggered
  12162. */
  12163. touchChanged: boolean;
  12164. /**
  12165. * Called when a value has changed
  12166. */
  12167. valueChanged: boolean;
  12168. }
  12169. /**
  12170. * Represents a gamepad
  12171. */
  12172. export class Gamepad {
  12173. /**
  12174. * The id of the gamepad
  12175. */
  12176. id: string;
  12177. /**
  12178. * The index of the gamepad
  12179. */
  12180. index: number;
  12181. /**
  12182. * The browser gamepad
  12183. */
  12184. browserGamepad: any;
  12185. /**
  12186. * Specifies what type of gamepad this represents
  12187. */
  12188. type: number;
  12189. private _leftStick;
  12190. private _rightStick;
  12191. /** @hidden */
  12192. _isConnected: boolean;
  12193. private _leftStickAxisX;
  12194. private _leftStickAxisY;
  12195. private _rightStickAxisX;
  12196. private _rightStickAxisY;
  12197. /**
  12198. * Triggered when the left control stick has been changed
  12199. */
  12200. private _onleftstickchanged;
  12201. /**
  12202. * Triggered when the right control stick has been changed
  12203. */
  12204. private _onrightstickchanged;
  12205. /**
  12206. * Represents a gamepad controller
  12207. */
  12208. static GAMEPAD: number;
  12209. /**
  12210. * Represents a generic controller
  12211. */
  12212. static GENERIC: number;
  12213. /**
  12214. * Represents an XBox controller
  12215. */
  12216. static XBOX: number;
  12217. /**
  12218. * Represents a pose-enabled controller
  12219. */
  12220. static POSE_ENABLED: number;
  12221. /**
  12222. * Represents an Dual Shock controller
  12223. */
  12224. static DUALSHOCK: number;
  12225. /**
  12226. * Specifies whether the left control stick should be Y-inverted
  12227. */
  12228. protected _invertLeftStickY: boolean;
  12229. /**
  12230. * Specifies if the gamepad has been connected
  12231. */
  12232. readonly isConnected: boolean;
  12233. /**
  12234. * Initializes the gamepad
  12235. * @param id The id of the gamepad
  12236. * @param index The index of the gamepad
  12237. * @param browserGamepad The browser gamepad
  12238. * @param leftStickX The x component of the left joystick
  12239. * @param leftStickY The y component of the left joystick
  12240. * @param rightStickX The x component of the right joystick
  12241. * @param rightStickY The y component of the right joystick
  12242. */
  12243. constructor(
  12244. /**
  12245. * The id of the gamepad
  12246. */
  12247. id: string,
  12248. /**
  12249. * The index of the gamepad
  12250. */
  12251. index: number,
  12252. /**
  12253. * The browser gamepad
  12254. */
  12255. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12256. /**
  12257. * Callback triggered when the left joystick has changed
  12258. * @param callback
  12259. */
  12260. onleftstickchanged(callback: (values: StickValues) => void): void;
  12261. /**
  12262. * Callback triggered when the right joystick has changed
  12263. * @param callback
  12264. */
  12265. onrightstickchanged(callback: (values: StickValues) => void): void;
  12266. /**
  12267. * Gets the left joystick
  12268. */
  12269. /**
  12270. * Sets the left joystick values
  12271. */
  12272. leftStick: StickValues;
  12273. /**
  12274. * Gets the right joystick
  12275. */
  12276. /**
  12277. * Sets the right joystick value
  12278. */
  12279. rightStick: StickValues;
  12280. /**
  12281. * Updates the gamepad joystick positions
  12282. */
  12283. update(): void;
  12284. /**
  12285. * Disposes the gamepad
  12286. */
  12287. dispose(): void;
  12288. }
  12289. /**
  12290. * Represents a generic gamepad
  12291. */
  12292. export class GenericPad extends Gamepad {
  12293. private _buttons;
  12294. private _onbuttondown;
  12295. private _onbuttonup;
  12296. /**
  12297. * Observable triggered when a button has been pressed
  12298. */
  12299. onButtonDownObservable: Observable<number>;
  12300. /**
  12301. * Observable triggered when a button has been released
  12302. */
  12303. onButtonUpObservable: Observable<number>;
  12304. /**
  12305. * Callback triggered when a button has been pressed
  12306. * @param callback Called when a button has been pressed
  12307. */
  12308. onbuttondown(callback: (buttonPressed: number) => void): void;
  12309. /**
  12310. * Callback triggered when a button has been released
  12311. * @param callback Called when a button has been released
  12312. */
  12313. onbuttonup(callback: (buttonReleased: number) => void): void;
  12314. /**
  12315. * Initializes the generic gamepad
  12316. * @param id The id of the generic gamepad
  12317. * @param index The index of the generic gamepad
  12318. * @param browserGamepad The browser gamepad
  12319. */
  12320. constructor(id: string, index: number, browserGamepad: any);
  12321. private _setButtonValue;
  12322. /**
  12323. * Updates the generic gamepad
  12324. */
  12325. update(): void;
  12326. /**
  12327. * Disposes the generic gamepad
  12328. */
  12329. dispose(): void;
  12330. }
  12331. }
  12332. declare module BABYLON {
  12333. interface Engine {
  12334. /**
  12335. * Creates a raw texture
  12336. * @param data defines the data to store in the texture
  12337. * @param width defines the width of the texture
  12338. * @param height defines the height of the texture
  12339. * @param format defines the format of the data
  12340. * @param generateMipMaps defines if the engine should generate the mip levels
  12341. * @param invertY defines if data must be stored with Y axis inverted
  12342. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12343. * @param compression defines the compression used (null by default)
  12344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12345. * @returns the raw texture inside an InternalTexture
  12346. */
  12347. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12348. /**
  12349. * Update a raw texture
  12350. * @param texture defines the texture to update
  12351. * @param data defines the data to store in the texture
  12352. * @param format defines the format of the data
  12353. * @param invertY defines if data must be stored with Y axis inverted
  12354. */
  12355. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12356. /**
  12357. * Update a raw texture
  12358. * @param texture defines the texture to update
  12359. * @param data defines the data to store in the texture
  12360. * @param format defines the format of the data
  12361. * @param invertY defines if data must be stored with Y axis inverted
  12362. * @param compression defines the compression used (null by default)
  12363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12364. */
  12365. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12366. /**
  12367. * Creates a new raw cube texture
  12368. * @param data defines the array of data to use to create each face
  12369. * @param size defines the size of the textures
  12370. * @param format defines the format of the data
  12371. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12372. * @param generateMipMaps defines if the engine should generate the mip levels
  12373. * @param invertY defines if data must be stored with Y axis inverted
  12374. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12375. * @param compression defines the compression used (null by default)
  12376. * @returns the cube texture as an InternalTexture
  12377. */
  12378. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12379. /**
  12380. * Update a raw cube texture
  12381. * @param texture defines the texture to udpdate
  12382. * @param data defines the data to store
  12383. * @param format defines the data format
  12384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12385. * @param invertY defines if data must be stored with Y axis inverted
  12386. */
  12387. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12388. /**
  12389. * Update a raw cube texture
  12390. * @param texture defines the texture to udpdate
  12391. * @param data defines the data to store
  12392. * @param format defines the data format
  12393. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12394. * @param invertY defines if data must be stored with Y axis inverted
  12395. * @param compression defines the compression used (null by default)
  12396. */
  12397. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12398. /**
  12399. * Update a raw cube texture
  12400. * @param texture defines the texture to udpdate
  12401. * @param data defines the data to store
  12402. * @param format defines the data format
  12403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12404. * @param invertY defines if data must be stored with Y axis inverted
  12405. * @param compression defines the compression used (null by default)
  12406. * @param level defines which level of the texture to update
  12407. */
  12408. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12409. /**
  12410. * Creates a new raw cube texture from a specified url
  12411. * @param url defines the url where the data is located
  12412. * @param scene defines the current scene
  12413. * @param size defines the size of the textures
  12414. * @param format defines the format of the data
  12415. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12416. * @param noMipmap defines if the engine should avoid generating the mip levels
  12417. * @param callback defines a callback used to extract texture data from loaded data
  12418. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12419. * @param onLoad defines a callback called when texture is loaded
  12420. * @param onError defines a callback called if there is an error
  12421. * @returns the cube texture as an InternalTexture
  12422. */
  12423. 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;
  12424. /**
  12425. * Creates a new raw cube texture from a specified url
  12426. * @param url defines the url where the data is located
  12427. * @param scene defines the current scene
  12428. * @param size defines the size of the textures
  12429. * @param format defines the format of the data
  12430. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12431. * @param noMipmap defines if the engine should avoid generating the mip levels
  12432. * @param callback defines a callback used to extract texture data from loaded data
  12433. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12434. * @param onLoad defines a callback called when texture is loaded
  12435. * @param onError defines a callback called if there is an error
  12436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12437. * @param invertY defines if data must be stored with Y axis inverted
  12438. * @returns the cube texture as an InternalTexture
  12439. */
  12440. 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;
  12441. /**
  12442. * Creates a new raw 3D texture
  12443. * @param data defines the data used to create the texture
  12444. * @param width defines the width of the texture
  12445. * @param height defines the height of the texture
  12446. * @param depth defines the depth of the texture
  12447. * @param format defines the format of the texture
  12448. * @param generateMipMaps defines if the engine must generate mip levels
  12449. * @param invertY defines if data must be stored with Y axis inverted
  12450. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12451. * @param compression defines the compressed used (can be null)
  12452. * @param textureType defines the compressed used (can be null)
  12453. * @returns a new raw 3D texture (stored in an InternalTexture)
  12454. */
  12455. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12456. /**
  12457. * Update a raw 3D texture
  12458. * @param texture defines the texture to update
  12459. * @param data defines the data to store
  12460. * @param format defines the data format
  12461. * @param invertY defines if data must be stored with Y axis inverted
  12462. */
  12463. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12464. /**
  12465. * Update a raw 3D texture
  12466. * @param texture defines the texture to update
  12467. * @param data defines the data to store
  12468. * @param format defines the data format
  12469. * @param invertY defines if data must be stored with Y axis inverted
  12470. * @param compression defines the used compression (can be null)
  12471. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12472. */
  12473. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12474. }
  12475. }
  12476. declare module BABYLON {
  12477. /**
  12478. * Raw texture can help creating a texture directly from an array of data.
  12479. * This can be super useful if you either get the data from an uncompressed source or
  12480. * if you wish to create your texture pixel by pixel.
  12481. */
  12482. export class RawTexture extends Texture {
  12483. /**
  12484. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12485. */
  12486. format: number;
  12487. private _engine;
  12488. /**
  12489. * Instantiates a new RawTexture.
  12490. * Raw texture can help creating a texture directly from an array of data.
  12491. * This can be super useful if you either get the data from an uncompressed source or
  12492. * if you wish to create your texture pixel by pixel.
  12493. * @param data define the array of data to use to create the texture
  12494. * @param width define the width of the texture
  12495. * @param height define the height of the texture
  12496. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12497. * @param scene define the scene the texture belongs to
  12498. * @param generateMipMaps define whether mip maps should be generated or not
  12499. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12500. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12501. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12502. */
  12503. constructor(data: ArrayBufferView, width: number, height: number,
  12504. /**
  12505. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12506. */
  12507. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12508. /**
  12509. * Updates the texture underlying data.
  12510. * @param data Define the new data of the texture
  12511. */
  12512. update(data: ArrayBufferView): void;
  12513. /**
  12514. * Creates a luminance texture from some data.
  12515. * @param data Define the texture data
  12516. * @param width Define the width of the texture
  12517. * @param height Define the height of the texture
  12518. * @param scene Define the scene the texture belongs to
  12519. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12520. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12521. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12522. * @returns the luminance texture
  12523. */
  12524. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12525. /**
  12526. * Creates a luminance alpha texture from some data.
  12527. * @param data Define the texture data
  12528. * @param width Define the width of the texture
  12529. * @param height Define the height of the texture
  12530. * @param scene Define the scene the texture belongs to
  12531. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12532. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12533. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12534. * @returns the luminance alpha texture
  12535. */
  12536. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12537. /**
  12538. * Creates an alpha texture from some data.
  12539. * @param data Define the texture data
  12540. * @param width Define the width of the texture
  12541. * @param height Define the height of the texture
  12542. * @param scene Define the scene the texture belongs to
  12543. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12546. * @returns the alpha texture
  12547. */
  12548. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12549. /**
  12550. * Creates a RGB texture from some data.
  12551. * @param data Define the texture data
  12552. * @param width Define the width of the texture
  12553. * @param height Define the height of the texture
  12554. * @param scene Define the scene the texture belongs to
  12555. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12556. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12557. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12558. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12559. * @returns the RGB alpha texture
  12560. */
  12561. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12562. /**
  12563. * Creates a RGBA texture from some data.
  12564. * @param data Define the texture data
  12565. * @param width Define the width of the texture
  12566. * @param height Define the height of the texture
  12567. * @param scene Define the scene the texture belongs to
  12568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12572. * @returns the RGBA texture
  12573. */
  12574. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12575. /**
  12576. * Creates a R texture from some data.
  12577. * @param data Define the texture data
  12578. * @param width Define the width of the texture
  12579. * @param height Define the height of the texture
  12580. * @param scene Define the scene the texture belongs to
  12581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12585. * @returns the R texture
  12586. */
  12587. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12588. }
  12589. }
  12590. declare module BABYLON {
  12591. /**
  12592. * Interface for the size containing width and height
  12593. */
  12594. export interface ISize {
  12595. /**
  12596. * Width
  12597. */
  12598. width: number;
  12599. /**
  12600. * Heighht
  12601. */
  12602. height: number;
  12603. }
  12604. /**
  12605. * Size containing widht and height
  12606. */
  12607. export class Size implements ISize {
  12608. /**
  12609. * Width
  12610. */
  12611. width: number;
  12612. /**
  12613. * Height
  12614. */
  12615. height: number;
  12616. /**
  12617. * Creates a Size object from the given width and height (floats).
  12618. * @param width width of the new size
  12619. * @param height height of the new size
  12620. */
  12621. constructor(width: number, height: number);
  12622. /**
  12623. * Returns a string with the Size width and height
  12624. * @returns a string with the Size width and height
  12625. */
  12626. toString(): string;
  12627. /**
  12628. * "Size"
  12629. * @returns the string "Size"
  12630. */
  12631. getClassName(): string;
  12632. /**
  12633. * Returns the Size hash code.
  12634. * @returns a hash code for a unique width and height
  12635. */
  12636. getHashCode(): number;
  12637. /**
  12638. * Updates the current size from the given one.
  12639. * @param src the given size
  12640. */
  12641. copyFrom(src: Size): void;
  12642. /**
  12643. * Updates in place the current Size from the given floats.
  12644. * @param width width of the new size
  12645. * @param height height of the new size
  12646. * @returns the updated Size.
  12647. */
  12648. copyFromFloats(width: number, height: number): Size;
  12649. /**
  12650. * Updates in place the current Size from the given floats.
  12651. * @param width width to set
  12652. * @param height height to set
  12653. * @returns the updated Size.
  12654. */
  12655. set(width: number, height: number): Size;
  12656. /**
  12657. * Multiplies the width and height by numbers
  12658. * @param w factor to multiple the width by
  12659. * @param h factor to multiple the height by
  12660. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12661. */
  12662. multiplyByFloats(w: number, h: number): Size;
  12663. /**
  12664. * Clones the size
  12665. * @returns a new Size copied from the given one.
  12666. */
  12667. clone(): Size;
  12668. /**
  12669. * True if the current Size and the given one width and height are strictly equal.
  12670. * @param other the other size to compare against
  12671. * @returns True if the current Size and the given one width and height are strictly equal.
  12672. */
  12673. equals(other: Size): boolean;
  12674. /**
  12675. * The surface of the Size : width * height (float).
  12676. */
  12677. readonly surface: number;
  12678. /**
  12679. * Create a new size of zero
  12680. * @returns a new Size set to (0.0, 0.0)
  12681. */
  12682. static Zero(): Size;
  12683. /**
  12684. * Sums the width and height of two sizes
  12685. * @param otherSize size to add to this size
  12686. * @returns a new Size set as the addition result of the current Size and the given one.
  12687. */
  12688. add(otherSize: Size): Size;
  12689. /**
  12690. * Subtracts the width and height of two
  12691. * @param otherSize size to subtract to this size
  12692. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12693. */
  12694. subtract(otherSize: Size): Size;
  12695. /**
  12696. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12697. * @param start starting size to lerp between
  12698. * @param end end size to lerp between
  12699. * @param amount amount to lerp between the start and end values
  12700. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12701. */
  12702. static Lerp(start: Size, end: Size, amount: number): Size;
  12703. }
  12704. }
  12705. declare module BABYLON {
  12706. /**
  12707. * Defines a runtime animation
  12708. */
  12709. export class RuntimeAnimation {
  12710. private _events;
  12711. /**
  12712. * The current frame of the runtime animation
  12713. */
  12714. private _currentFrame;
  12715. /**
  12716. * The animation used by the runtime animation
  12717. */
  12718. private _animation;
  12719. /**
  12720. * The target of the runtime animation
  12721. */
  12722. private _target;
  12723. /**
  12724. * The initiating animatable
  12725. */
  12726. private _host;
  12727. /**
  12728. * The original value of the runtime animation
  12729. */
  12730. private _originalValue;
  12731. /**
  12732. * The original blend value of the runtime animation
  12733. */
  12734. private _originalBlendValue;
  12735. /**
  12736. * The offsets cache of the runtime animation
  12737. */
  12738. private _offsetsCache;
  12739. /**
  12740. * The high limits cache of the runtime animation
  12741. */
  12742. private _highLimitsCache;
  12743. /**
  12744. * Specifies if the runtime animation has been stopped
  12745. */
  12746. private _stopped;
  12747. /**
  12748. * The blending factor of the runtime animation
  12749. */
  12750. private _blendingFactor;
  12751. /**
  12752. * The BabylonJS scene
  12753. */
  12754. private _scene;
  12755. /**
  12756. * The current value of the runtime animation
  12757. */
  12758. private _currentValue;
  12759. /** @hidden */
  12760. _animationState: _IAnimationState;
  12761. /**
  12762. * The active target of the runtime animation
  12763. */
  12764. private _activeTargets;
  12765. private _currentActiveTarget;
  12766. private _directTarget;
  12767. /**
  12768. * The target path of the runtime animation
  12769. */
  12770. private _targetPath;
  12771. /**
  12772. * The weight of the runtime animation
  12773. */
  12774. private _weight;
  12775. /**
  12776. * The ratio offset of the runtime animation
  12777. */
  12778. private _ratioOffset;
  12779. /**
  12780. * The previous delay of the runtime animation
  12781. */
  12782. private _previousDelay;
  12783. /**
  12784. * The previous ratio of the runtime animation
  12785. */
  12786. private _previousRatio;
  12787. private _enableBlending;
  12788. private _keys;
  12789. private _minFrame;
  12790. private _maxFrame;
  12791. private _minValue;
  12792. private _maxValue;
  12793. private _targetIsArray;
  12794. /**
  12795. * Gets the current frame of the runtime animation
  12796. */
  12797. readonly currentFrame: number;
  12798. /**
  12799. * Gets the weight of the runtime animation
  12800. */
  12801. readonly weight: number;
  12802. /**
  12803. * Gets the current value of the runtime animation
  12804. */
  12805. readonly currentValue: any;
  12806. /**
  12807. * Gets the target path of the runtime animation
  12808. */
  12809. readonly targetPath: string;
  12810. /**
  12811. * Gets the actual target of the runtime animation
  12812. */
  12813. readonly target: any;
  12814. /** @hidden */
  12815. _onLoop: () => void;
  12816. /**
  12817. * Create a new RuntimeAnimation object
  12818. * @param target defines the target of the animation
  12819. * @param animation defines the source animation object
  12820. * @param scene defines the hosting scene
  12821. * @param host defines the initiating Animatable
  12822. */
  12823. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12824. private _preparePath;
  12825. /**
  12826. * Gets the animation from the runtime animation
  12827. */
  12828. readonly animation: Animation;
  12829. /**
  12830. * Resets the runtime animation to the beginning
  12831. * @param restoreOriginal defines whether to restore the target property to the original value
  12832. */
  12833. reset(restoreOriginal?: boolean): void;
  12834. /**
  12835. * Specifies if the runtime animation is stopped
  12836. * @returns Boolean specifying if the runtime animation is stopped
  12837. */
  12838. isStopped(): boolean;
  12839. /**
  12840. * Disposes of the runtime animation
  12841. */
  12842. dispose(): void;
  12843. /**
  12844. * Apply the interpolated value to the target
  12845. * @param currentValue defines the value computed by the animation
  12846. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12847. */
  12848. setValue(currentValue: any, weight: number): void;
  12849. private _getOriginalValues;
  12850. private _setValue;
  12851. /**
  12852. * Gets the loop pmode of the runtime animation
  12853. * @returns Loop Mode
  12854. */
  12855. private _getCorrectLoopMode;
  12856. /**
  12857. * Move the current animation to a given frame
  12858. * @param frame defines the frame to move to
  12859. */
  12860. goToFrame(frame: number): void;
  12861. /**
  12862. * @hidden Internal use only
  12863. */
  12864. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12865. /**
  12866. * Execute the current animation
  12867. * @param delay defines the delay to add to the current frame
  12868. * @param from defines the lower bound of the animation range
  12869. * @param to defines the upper bound of the animation range
  12870. * @param loop defines if the current animation must loop
  12871. * @param speedRatio defines the current speed ratio
  12872. * @param weight defines the weight of the animation (default is -1 so no weight)
  12873. * @param onLoop optional callback called when animation loops
  12874. * @returns a boolean indicating if the animation is running
  12875. */
  12876. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12877. }
  12878. }
  12879. declare module BABYLON {
  12880. /**
  12881. * Class used to store an actual running animation
  12882. */
  12883. export class Animatable {
  12884. /** defines the target object */
  12885. target: any;
  12886. /** defines the starting frame number (default is 0) */
  12887. fromFrame: number;
  12888. /** defines the ending frame number (default is 100) */
  12889. toFrame: number;
  12890. /** defines if the animation must loop (default is false) */
  12891. loopAnimation: boolean;
  12892. /** defines a callback to call when animation ends if it is not looping */
  12893. onAnimationEnd?: (() => void) | null | undefined;
  12894. /** defines a callback to call when animation loops */
  12895. onAnimationLoop?: (() => void) | null | undefined;
  12896. private _localDelayOffset;
  12897. private _pausedDelay;
  12898. private _runtimeAnimations;
  12899. private _paused;
  12900. private _scene;
  12901. private _speedRatio;
  12902. private _weight;
  12903. private _syncRoot;
  12904. /**
  12905. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12906. * This will only apply for non looping animation (default is true)
  12907. */
  12908. disposeOnEnd: boolean;
  12909. /**
  12910. * Gets a boolean indicating if the animation has started
  12911. */
  12912. animationStarted: boolean;
  12913. /**
  12914. * Observer raised when the animation ends
  12915. */
  12916. onAnimationEndObservable: Observable<Animatable>;
  12917. /**
  12918. * Observer raised when the animation loops
  12919. */
  12920. onAnimationLoopObservable: Observable<Animatable>;
  12921. /**
  12922. * Gets the root Animatable used to synchronize and normalize animations
  12923. */
  12924. readonly syncRoot: Nullable<Animatable>;
  12925. /**
  12926. * Gets the current frame of the first RuntimeAnimation
  12927. * Used to synchronize Animatables
  12928. */
  12929. readonly masterFrame: number;
  12930. /**
  12931. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12932. */
  12933. weight: number;
  12934. /**
  12935. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12936. */
  12937. speedRatio: number;
  12938. /**
  12939. * Creates a new Animatable
  12940. * @param scene defines the hosting scene
  12941. * @param target defines the target object
  12942. * @param fromFrame defines the starting frame number (default is 0)
  12943. * @param toFrame defines the ending frame number (default is 100)
  12944. * @param loopAnimation defines if the animation must loop (default is false)
  12945. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12946. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12947. * @param animations defines a group of animation to add to the new Animatable
  12948. * @param onAnimationLoop defines a callback to call when animation loops
  12949. */
  12950. constructor(scene: Scene,
  12951. /** defines the target object */
  12952. target: any,
  12953. /** defines the starting frame number (default is 0) */
  12954. fromFrame?: number,
  12955. /** defines the ending frame number (default is 100) */
  12956. toFrame?: number,
  12957. /** defines if the animation must loop (default is false) */
  12958. loopAnimation?: boolean, speedRatio?: number,
  12959. /** defines a callback to call when animation ends if it is not looping */
  12960. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12961. /** defines a callback to call when animation loops */
  12962. onAnimationLoop?: (() => void) | null | undefined);
  12963. /**
  12964. * Synchronize and normalize current Animatable with a source Animatable
  12965. * This is useful when using animation weights and when animations are not of the same length
  12966. * @param root defines the root Animatable to synchronize with
  12967. * @returns the current Animatable
  12968. */
  12969. syncWith(root: Animatable): Animatable;
  12970. /**
  12971. * Gets the list of runtime animations
  12972. * @returns an array of RuntimeAnimation
  12973. */
  12974. getAnimations(): RuntimeAnimation[];
  12975. /**
  12976. * Adds more animations to the current animatable
  12977. * @param target defines the target of the animations
  12978. * @param animations defines the new animations to add
  12979. */
  12980. appendAnimations(target: any, animations: Animation[]): void;
  12981. /**
  12982. * Gets the source animation for a specific property
  12983. * @param property defines the propertyu to look for
  12984. * @returns null or the source animation for the given property
  12985. */
  12986. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12987. /**
  12988. * Gets the runtime animation for a specific property
  12989. * @param property defines the propertyu to look for
  12990. * @returns null or the runtime animation for the given property
  12991. */
  12992. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12993. /**
  12994. * Resets the animatable to its original state
  12995. */
  12996. reset(): void;
  12997. /**
  12998. * Allows the animatable to blend with current running animations
  12999. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13000. * @param blendingSpeed defines the blending speed to use
  13001. */
  13002. enableBlending(blendingSpeed: number): void;
  13003. /**
  13004. * Disable animation blending
  13005. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13006. */
  13007. disableBlending(): void;
  13008. /**
  13009. * Jump directly to a given frame
  13010. * @param frame defines the frame to jump to
  13011. */
  13012. goToFrame(frame: number): void;
  13013. /**
  13014. * Pause the animation
  13015. */
  13016. pause(): void;
  13017. /**
  13018. * Restart the animation
  13019. */
  13020. restart(): void;
  13021. private _raiseOnAnimationEnd;
  13022. /**
  13023. * Stop and delete the current animation
  13024. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13025. * @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)
  13026. */
  13027. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13028. /**
  13029. * Wait asynchronously for the animation to end
  13030. * @returns a promise which will be fullfilled when the animation ends
  13031. */
  13032. waitAsync(): Promise<Animatable>;
  13033. /** @hidden */
  13034. _animate(delay: number): boolean;
  13035. }
  13036. interface Scene {
  13037. /** @hidden */
  13038. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13039. /** @hidden */
  13040. _processLateAnimationBindingsForMatrices(holder: {
  13041. totalWeight: number;
  13042. animations: RuntimeAnimation[];
  13043. originalValue: Matrix;
  13044. }): any;
  13045. /** @hidden */
  13046. _processLateAnimationBindingsForQuaternions(holder: {
  13047. totalWeight: number;
  13048. animations: RuntimeAnimation[];
  13049. originalValue: Quaternion;
  13050. }, refQuaternion: Quaternion): Quaternion;
  13051. /** @hidden */
  13052. _processLateAnimationBindings(): void;
  13053. /**
  13054. * Will start the animation sequence of a given target
  13055. * @param target defines the target
  13056. * @param from defines from which frame should animation start
  13057. * @param to defines until which frame should animation run.
  13058. * @param weight defines the weight to apply to the animation (1.0 by default)
  13059. * @param loop defines if the animation loops
  13060. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13061. * @param onAnimationEnd defines the function to be executed when the animation ends
  13062. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13063. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13064. * @param onAnimationLoop defines the callback to call when an animation loops
  13065. * @returns the animatable object created for this animation
  13066. */
  13067. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13068. /**
  13069. * Will start the animation sequence of a given target
  13070. * @param target defines the target
  13071. * @param from defines from which frame should animation start
  13072. * @param to defines until which frame should animation run.
  13073. * @param loop defines if the animation loops
  13074. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13075. * @param onAnimationEnd defines the function to be executed when the animation ends
  13076. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13077. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13078. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13079. * @param onAnimationLoop defines the callback to call when an animation loops
  13080. * @returns the animatable object created for this animation
  13081. */
  13082. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13083. /**
  13084. * Will start the animation sequence of a given target and its hierarchy
  13085. * @param target defines the target
  13086. * @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.
  13087. * @param from defines from which frame should animation start
  13088. * @param to defines until which frame should animation run.
  13089. * @param loop defines if the animation loops
  13090. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13091. * @param onAnimationEnd defines the function to be executed when the animation ends
  13092. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13093. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13094. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13095. * @param onAnimationLoop defines the callback to call when an animation loops
  13096. * @returns the list of created animatables
  13097. */
  13098. 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[];
  13099. /**
  13100. * Begin a new animation on a given node
  13101. * @param target defines the target where the animation will take place
  13102. * @param animations defines the list of animations to start
  13103. * @param from defines the initial value
  13104. * @param to defines the final value
  13105. * @param loop defines if you want animation to loop (off by default)
  13106. * @param speedRatio defines the speed ratio to apply to all animations
  13107. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13108. * @param onAnimationLoop defines the callback to call when an animation loops
  13109. * @returns the list of created animatables
  13110. */
  13111. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13112. /**
  13113. * Begin a new animation on a given node and its hierarchy
  13114. * @param target defines the root node where the animation will take place
  13115. * @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.
  13116. * @param animations defines the list of animations to start
  13117. * @param from defines the initial value
  13118. * @param to defines the final value
  13119. * @param loop defines if you want animation to loop (off by default)
  13120. * @param speedRatio defines the speed ratio to apply to all animations
  13121. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13122. * @param onAnimationLoop defines the callback to call when an animation loops
  13123. * @returns the list of animatables created for all nodes
  13124. */
  13125. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13126. /**
  13127. * Gets the animatable associated with a specific target
  13128. * @param target defines the target of the animatable
  13129. * @returns the required animatable if found
  13130. */
  13131. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13132. /**
  13133. * Gets all animatables associated with a given target
  13134. * @param target defines the target to look animatables for
  13135. * @returns an array of Animatables
  13136. */
  13137. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13138. /**
  13139. * Stops and removes all animations that have been applied to the scene
  13140. */
  13141. stopAllAnimations(): void;
  13142. }
  13143. interface Bone {
  13144. /**
  13145. * Copy an animation range from another bone
  13146. * @param source defines the source bone
  13147. * @param rangeName defines the range name to copy
  13148. * @param frameOffset defines the frame offset
  13149. * @param rescaleAsRequired defines if rescaling must be applied if required
  13150. * @param skelDimensionsRatio defines the scaling ratio
  13151. * @returns true if operation was successful
  13152. */
  13153. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13154. }
  13155. }
  13156. declare module BABYLON {
  13157. /**
  13158. * Class used to override all child animations of a given target
  13159. */
  13160. export class AnimationPropertiesOverride {
  13161. /**
  13162. * Gets or sets a value indicating if animation blending must be used
  13163. */
  13164. enableBlending: boolean;
  13165. /**
  13166. * Gets or sets the blending speed to use when enableBlending is true
  13167. */
  13168. blendingSpeed: number;
  13169. /**
  13170. * Gets or sets the default loop mode to use
  13171. */
  13172. loopMode: number;
  13173. }
  13174. }
  13175. declare module BABYLON {
  13176. /**
  13177. * Class used to handle skinning animations
  13178. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13179. */
  13180. export class Skeleton implements IAnimatable {
  13181. /** defines the skeleton name */
  13182. name: string;
  13183. /** defines the skeleton Id */
  13184. id: string;
  13185. /**
  13186. * Defines the list of child bones
  13187. */
  13188. bones: Bone[];
  13189. /**
  13190. * Defines an estimate of the dimension of the skeleton at rest
  13191. */
  13192. dimensionsAtRest: Vector3;
  13193. /**
  13194. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13195. */
  13196. needInitialSkinMatrix: boolean;
  13197. /**
  13198. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13199. */
  13200. overrideMesh: Nullable<AbstractMesh>;
  13201. /**
  13202. * Gets the list of animations attached to this skeleton
  13203. */
  13204. animations: Array<Animation>;
  13205. private _scene;
  13206. private _isDirty;
  13207. private _transformMatrices;
  13208. private _transformMatrixTexture;
  13209. private _meshesWithPoseMatrix;
  13210. private _animatables;
  13211. private _identity;
  13212. private _synchronizedWithMesh;
  13213. private _ranges;
  13214. private _lastAbsoluteTransformsUpdateId;
  13215. private _canUseTextureForBones;
  13216. private _uniqueId;
  13217. /** @hidden */
  13218. _numBonesWithLinkedTransformNode: number;
  13219. /** @hidden */
  13220. _hasWaitingData: Nullable<boolean>;
  13221. /**
  13222. * Specifies if the skeleton should be serialized
  13223. */
  13224. doNotSerialize: boolean;
  13225. private _useTextureToStoreBoneMatrices;
  13226. /**
  13227. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13228. * Please note that this option is not available if the hardware does not support it
  13229. */
  13230. useTextureToStoreBoneMatrices: boolean;
  13231. private _animationPropertiesOverride;
  13232. /**
  13233. * Gets or sets the animation properties override
  13234. */
  13235. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13236. /**
  13237. * List of inspectable custom properties (used by the Inspector)
  13238. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13239. */
  13240. inspectableCustomProperties: IInspectable[];
  13241. /**
  13242. * An observable triggered before computing the skeleton's matrices
  13243. */
  13244. onBeforeComputeObservable: Observable<Skeleton>;
  13245. /**
  13246. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13247. */
  13248. readonly isUsingTextureForMatrices: boolean;
  13249. /**
  13250. * Gets the unique ID of this skeleton
  13251. */
  13252. readonly uniqueId: number;
  13253. /**
  13254. * Creates a new skeleton
  13255. * @param name defines the skeleton name
  13256. * @param id defines the skeleton Id
  13257. * @param scene defines the hosting scene
  13258. */
  13259. constructor(
  13260. /** defines the skeleton name */
  13261. name: string,
  13262. /** defines the skeleton Id */
  13263. id: string, scene: Scene);
  13264. /**
  13265. * Gets the current object class name.
  13266. * @return the class name
  13267. */
  13268. getClassName(): string;
  13269. /**
  13270. * Returns an array containing the root bones
  13271. * @returns an array containing the root bones
  13272. */
  13273. getChildren(): Array<Bone>;
  13274. /**
  13275. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13276. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13277. * @returns a Float32Array containing matrices data
  13278. */
  13279. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13280. /**
  13281. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13282. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13283. * @returns a raw texture containing the data
  13284. */
  13285. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13286. /**
  13287. * Gets the current hosting scene
  13288. * @returns a scene object
  13289. */
  13290. getScene(): Scene;
  13291. /**
  13292. * Gets a string representing the current skeleton data
  13293. * @param fullDetails defines a boolean indicating if we want a verbose version
  13294. * @returns a string representing the current skeleton data
  13295. */
  13296. toString(fullDetails?: boolean): string;
  13297. /**
  13298. * Get bone's index searching by name
  13299. * @param name defines bone's name to search for
  13300. * @return the indice of the bone. Returns -1 if not found
  13301. */
  13302. getBoneIndexByName(name: string): number;
  13303. /**
  13304. * Creater a new animation range
  13305. * @param name defines the name of the range
  13306. * @param from defines the start key
  13307. * @param to defines the end key
  13308. */
  13309. createAnimationRange(name: string, from: number, to: number): void;
  13310. /**
  13311. * Delete a specific animation range
  13312. * @param name defines the name of the range
  13313. * @param deleteFrames defines if frames must be removed as well
  13314. */
  13315. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13316. /**
  13317. * Gets a specific animation range
  13318. * @param name defines the name of the range to look for
  13319. * @returns the requested animation range or null if not found
  13320. */
  13321. getAnimationRange(name: string): Nullable<AnimationRange>;
  13322. /**
  13323. * Gets the list of all animation ranges defined on this skeleton
  13324. * @returns an array
  13325. */
  13326. getAnimationRanges(): Nullable<AnimationRange>[];
  13327. /**
  13328. * Copy animation range from a source skeleton.
  13329. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13330. * @param source defines the source skeleton
  13331. * @param name defines the name of the range to copy
  13332. * @param rescaleAsRequired defines if rescaling must be applied if required
  13333. * @returns true if operation was successful
  13334. */
  13335. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13336. /**
  13337. * Forces the skeleton to go to rest pose
  13338. */
  13339. returnToRest(): void;
  13340. private _getHighestAnimationFrame;
  13341. /**
  13342. * Begin a specific animation range
  13343. * @param name defines the name of the range to start
  13344. * @param loop defines if looping must be turned on (false by default)
  13345. * @param speedRatio defines the speed ratio to apply (1 by default)
  13346. * @param onAnimationEnd defines a callback which will be called when animation will end
  13347. * @returns a new animatable
  13348. */
  13349. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13350. /** @hidden */
  13351. _markAsDirty(): void;
  13352. /** @hidden */
  13353. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13354. /** @hidden */
  13355. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13356. private _computeTransformMatrices;
  13357. /**
  13358. * Build all resources required to render a skeleton
  13359. */
  13360. prepare(): void;
  13361. /**
  13362. * Gets the list of animatables currently running for this skeleton
  13363. * @returns an array of animatables
  13364. */
  13365. getAnimatables(): IAnimatable[];
  13366. /**
  13367. * Clone the current skeleton
  13368. * @param name defines the name of the new skeleton
  13369. * @param id defines the id of the new skeleton
  13370. * @returns the new skeleton
  13371. */
  13372. clone(name: string, id: string): Skeleton;
  13373. /**
  13374. * Enable animation blending for this skeleton
  13375. * @param blendingSpeed defines the blending speed to apply
  13376. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13377. */
  13378. enableBlending(blendingSpeed?: number): void;
  13379. /**
  13380. * Releases all resources associated with the current skeleton
  13381. */
  13382. dispose(): void;
  13383. /**
  13384. * Serialize the skeleton in a JSON object
  13385. * @returns a JSON object
  13386. */
  13387. serialize(): any;
  13388. /**
  13389. * Creates a new skeleton from serialized data
  13390. * @param parsedSkeleton defines the serialized data
  13391. * @param scene defines the hosting scene
  13392. * @returns a new skeleton
  13393. */
  13394. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13395. /**
  13396. * Compute all node absolute transforms
  13397. * @param forceUpdate defines if computation must be done even if cache is up to date
  13398. */
  13399. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13400. /**
  13401. * Gets the root pose matrix
  13402. * @returns a matrix
  13403. */
  13404. getPoseMatrix(): Nullable<Matrix>;
  13405. /**
  13406. * Sorts bones per internal index
  13407. */
  13408. sortBones(): void;
  13409. private _sortBones;
  13410. }
  13411. }
  13412. declare module BABYLON {
  13413. /**
  13414. * Class used to store bone information
  13415. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13416. */
  13417. export class Bone extends Node {
  13418. /**
  13419. * defines the bone name
  13420. */
  13421. name: string;
  13422. private static _tmpVecs;
  13423. private static _tmpQuat;
  13424. private static _tmpMats;
  13425. /**
  13426. * Gets the list of child bones
  13427. */
  13428. children: Bone[];
  13429. /** Gets the animations associated with this bone */
  13430. animations: Animation[];
  13431. /**
  13432. * Gets or sets bone length
  13433. */
  13434. length: number;
  13435. /**
  13436. * @hidden Internal only
  13437. * Set this value to map this bone to a different index in the transform matrices
  13438. * Set this value to -1 to exclude the bone from the transform matrices
  13439. */
  13440. _index: Nullable<number>;
  13441. private _skeleton;
  13442. private _localMatrix;
  13443. private _restPose;
  13444. private _baseMatrix;
  13445. private _absoluteTransform;
  13446. private _invertedAbsoluteTransform;
  13447. private _parent;
  13448. private _scalingDeterminant;
  13449. private _worldTransform;
  13450. private _localScaling;
  13451. private _localRotation;
  13452. private _localPosition;
  13453. private _needToDecompose;
  13454. private _needToCompose;
  13455. /** @hidden */
  13456. _linkedTransformNode: Nullable<TransformNode>;
  13457. /** @hidden */
  13458. _waitingTransformNodeId: Nullable<string>;
  13459. /** @hidden */
  13460. /** @hidden */
  13461. _matrix: Matrix;
  13462. /**
  13463. * Create a new bone
  13464. * @param name defines the bone name
  13465. * @param skeleton defines the parent skeleton
  13466. * @param parentBone defines the parent (can be null if the bone is the root)
  13467. * @param localMatrix defines the local matrix
  13468. * @param restPose defines the rest pose matrix
  13469. * @param baseMatrix defines the base matrix
  13470. * @param index defines index of the bone in the hiearchy
  13471. */
  13472. constructor(
  13473. /**
  13474. * defines the bone name
  13475. */
  13476. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13477. /**
  13478. * Gets the current object class name.
  13479. * @return the class name
  13480. */
  13481. getClassName(): string;
  13482. /**
  13483. * Gets the parent skeleton
  13484. * @returns a skeleton
  13485. */
  13486. getSkeleton(): Skeleton;
  13487. /**
  13488. * Gets parent bone
  13489. * @returns a bone or null if the bone is the root of the bone hierarchy
  13490. */
  13491. getParent(): Nullable<Bone>;
  13492. /**
  13493. * Returns an array containing the root bones
  13494. * @returns an array containing the root bones
  13495. */
  13496. getChildren(): Array<Bone>;
  13497. /**
  13498. * Sets the parent bone
  13499. * @param parent defines the parent (can be null if the bone is the root)
  13500. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13501. */
  13502. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13503. /**
  13504. * Gets the local matrix
  13505. * @returns a matrix
  13506. */
  13507. getLocalMatrix(): Matrix;
  13508. /**
  13509. * Gets the base matrix (initial matrix which remains unchanged)
  13510. * @returns a matrix
  13511. */
  13512. getBaseMatrix(): Matrix;
  13513. /**
  13514. * Gets the rest pose matrix
  13515. * @returns a matrix
  13516. */
  13517. getRestPose(): Matrix;
  13518. /**
  13519. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13520. */
  13521. getWorldMatrix(): Matrix;
  13522. /**
  13523. * Sets the local matrix to rest pose matrix
  13524. */
  13525. returnToRest(): void;
  13526. /**
  13527. * Gets the inverse of the absolute transform matrix.
  13528. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13529. * @returns a matrix
  13530. */
  13531. getInvertedAbsoluteTransform(): Matrix;
  13532. /**
  13533. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13534. * @returns a matrix
  13535. */
  13536. getAbsoluteTransform(): Matrix;
  13537. /**
  13538. * Links with the given transform node.
  13539. * The local matrix of this bone is copied from the transform node every frame.
  13540. * @param transformNode defines the transform node to link to
  13541. */
  13542. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13543. /**
  13544. * Gets the node used to drive the bone's transformation
  13545. * @returns a transform node or null
  13546. */
  13547. getTransformNode(): Nullable<TransformNode>;
  13548. /** Gets or sets current position (in local space) */
  13549. position: Vector3;
  13550. /** Gets or sets current rotation (in local space) */
  13551. rotation: Vector3;
  13552. /** Gets or sets current rotation quaternion (in local space) */
  13553. rotationQuaternion: Quaternion;
  13554. /** Gets or sets current scaling (in local space) */
  13555. scaling: Vector3;
  13556. /**
  13557. * Gets the animation properties override
  13558. */
  13559. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13560. private _decompose;
  13561. private _compose;
  13562. /**
  13563. * Update the base and local matrices
  13564. * @param matrix defines the new base or local matrix
  13565. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13566. * @param updateLocalMatrix defines if the local matrix should be updated
  13567. */
  13568. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13569. /** @hidden */
  13570. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13571. /**
  13572. * Flag the bone as dirty (Forcing it to update everything)
  13573. */
  13574. markAsDirty(): void;
  13575. /** @hidden */
  13576. _markAsDirtyAndCompose(): void;
  13577. private _markAsDirtyAndDecompose;
  13578. /**
  13579. * Translate the bone in local or world space
  13580. * @param vec The amount to translate the bone
  13581. * @param space The space that the translation is in
  13582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13583. */
  13584. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13585. /**
  13586. * Set the postion of the bone in local or world space
  13587. * @param position The position to set the bone
  13588. * @param space The space that the position is in
  13589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13590. */
  13591. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13592. /**
  13593. * Set the absolute position of the bone (world space)
  13594. * @param position The position to set the bone
  13595. * @param mesh The mesh that this bone is attached to
  13596. */
  13597. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13598. /**
  13599. * Scale the bone on the x, y and z axes (in local space)
  13600. * @param x The amount to scale the bone on the x axis
  13601. * @param y The amount to scale the bone on the y axis
  13602. * @param z The amount to scale the bone on the z axis
  13603. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13604. */
  13605. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13606. /**
  13607. * Set the bone scaling in local space
  13608. * @param scale defines the scaling vector
  13609. */
  13610. setScale(scale: Vector3): void;
  13611. /**
  13612. * Gets the current scaling in local space
  13613. * @returns the current scaling vector
  13614. */
  13615. getScale(): Vector3;
  13616. /**
  13617. * Gets the current scaling in local space and stores it in a target vector
  13618. * @param result defines the target vector
  13619. */
  13620. getScaleToRef(result: Vector3): void;
  13621. /**
  13622. * Set the yaw, pitch, and roll of the bone in local or world space
  13623. * @param yaw The rotation of the bone on the y axis
  13624. * @param pitch The rotation of the bone on the x axis
  13625. * @param roll The rotation of the bone on the z axis
  13626. * @param space The space that the axes of rotation are in
  13627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13628. */
  13629. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13630. /**
  13631. * Add a rotation to the bone on an axis in local or world space
  13632. * @param axis The axis to rotate the bone on
  13633. * @param amount The amount to rotate the bone
  13634. * @param space The space that the axis is in
  13635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13636. */
  13637. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13638. /**
  13639. * Set the rotation of the bone to a particular axis angle in local or world space
  13640. * @param axis The axis to rotate the bone on
  13641. * @param angle The angle that the bone should be rotated to
  13642. * @param space The space that the axis is in
  13643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13644. */
  13645. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13646. /**
  13647. * Set the euler rotation of the bone in local of world space
  13648. * @param rotation The euler rotation that the bone should be set to
  13649. * @param space The space that the rotation is in
  13650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13651. */
  13652. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13653. /**
  13654. * Set the quaternion rotation of the bone in local of world space
  13655. * @param quat The quaternion rotation that the bone should be set to
  13656. * @param space The space that the rotation is in
  13657. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13658. */
  13659. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13660. /**
  13661. * Set the rotation matrix of the bone in local of world space
  13662. * @param rotMat The rotation matrix that the bone should be set to
  13663. * @param space The space that the rotation is in
  13664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13665. */
  13666. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13667. private _rotateWithMatrix;
  13668. private _getNegativeRotationToRef;
  13669. /**
  13670. * Get the position of the bone in local or world space
  13671. * @param space The space that the returned position is in
  13672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13673. * @returns The position of the bone
  13674. */
  13675. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13676. /**
  13677. * Copy the position of the bone to a vector3 in local or world space
  13678. * @param space The space that the returned position is in
  13679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13680. * @param result The vector3 to copy the position to
  13681. */
  13682. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13683. /**
  13684. * Get the absolute position of the bone (world space)
  13685. * @param mesh The mesh that this bone is attached to
  13686. * @returns The absolute position of the bone
  13687. */
  13688. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13689. /**
  13690. * Copy the absolute position of the bone (world space) to the result param
  13691. * @param mesh The mesh that this bone is attached to
  13692. * @param result The vector3 to copy the absolute position to
  13693. */
  13694. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13695. /**
  13696. * Compute the absolute transforms of this bone and its children
  13697. */
  13698. computeAbsoluteTransforms(): void;
  13699. /**
  13700. * Get the world direction from an axis that is in the local space of the bone
  13701. * @param localAxis The local direction that is used to compute the world direction
  13702. * @param mesh The mesh that this bone is attached to
  13703. * @returns The world direction
  13704. */
  13705. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13706. /**
  13707. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13708. * @param localAxis The local direction that is used to compute the world direction
  13709. * @param mesh The mesh that this bone is attached to
  13710. * @param result The vector3 that the world direction will be copied to
  13711. */
  13712. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13713. /**
  13714. * Get the euler rotation of the bone in local or world space
  13715. * @param space The space that the rotation should be in
  13716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13717. * @returns The euler rotation
  13718. */
  13719. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13720. /**
  13721. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13722. * @param space The space that the rotation should be in
  13723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13724. * @param result The vector3 that the rotation should be copied to
  13725. */
  13726. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13727. /**
  13728. * Get the quaternion rotation of the bone in either local or world space
  13729. * @param space The space that the rotation should be in
  13730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13731. * @returns The quaternion rotation
  13732. */
  13733. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13734. /**
  13735. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13736. * @param space The space that the rotation should be in
  13737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13738. * @param result The quaternion that the rotation should be copied to
  13739. */
  13740. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13741. /**
  13742. * Get the rotation matrix of the bone in local or world space
  13743. * @param space The space that the rotation should be in
  13744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13745. * @returns The rotation matrix
  13746. */
  13747. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13748. /**
  13749. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13750. * @param space The space that the rotation should be in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. * @param result The quaternion that the rotation should be copied to
  13753. */
  13754. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13755. /**
  13756. * Get the world position of a point that is in the local space of the bone
  13757. * @param position The local position
  13758. * @param mesh The mesh that this bone is attached to
  13759. * @returns The world position
  13760. */
  13761. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13762. /**
  13763. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13764. * @param position The local position
  13765. * @param mesh The mesh that this bone is attached to
  13766. * @param result The vector3 that the world position should be copied to
  13767. */
  13768. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13769. /**
  13770. * Get the local position of a point that is in world space
  13771. * @param position The world position
  13772. * @param mesh The mesh that this bone is attached to
  13773. * @returns The local position
  13774. */
  13775. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13776. /**
  13777. * Get the local position of a point that is in world space and copy it to the result param
  13778. * @param position The world position
  13779. * @param mesh The mesh that this bone is attached to
  13780. * @param result The vector3 that the local position should be copied to
  13781. */
  13782. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13783. }
  13784. }
  13785. declare module BABYLON {
  13786. /**
  13787. * 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.
  13788. * @see https://doc.babylonjs.com/how_to/transformnode
  13789. */
  13790. export class TransformNode extends Node {
  13791. /**
  13792. * Object will not rotate to face the camera
  13793. */
  13794. static BILLBOARDMODE_NONE: number;
  13795. /**
  13796. * Object will rotate to face the camera but only on the x axis
  13797. */
  13798. static BILLBOARDMODE_X: number;
  13799. /**
  13800. * Object will rotate to face the camera but only on the y axis
  13801. */
  13802. static BILLBOARDMODE_Y: number;
  13803. /**
  13804. * Object will rotate to face the camera but only on the z axis
  13805. */
  13806. static BILLBOARDMODE_Z: number;
  13807. /**
  13808. * Object will rotate to face the camera
  13809. */
  13810. static BILLBOARDMODE_ALL: number;
  13811. /**
  13812. * Object will rotate to face the camera's position instead of orientation
  13813. */
  13814. static BILLBOARDMODE_USE_POSITION: number;
  13815. private _forward;
  13816. private _forwardInverted;
  13817. private _up;
  13818. private _right;
  13819. private _rightInverted;
  13820. private _position;
  13821. private _rotation;
  13822. private _rotationQuaternion;
  13823. protected _scaling: Vector3;
  13824. protected _isDirty: boolean;
  13825. private _transformToBoneReferal;
  13826. private _isAbsoluteSynced;
  13827. private _billboardMode;
  13828. /**
  13829. * Gets or sets the billboard mode. Default is 0.
  13830. *
  13831. * | Value | Type | Description |
  13832. * | --- | --- | --- |
  13833. * | 0 | BILLBOARDMODE_NONE | |
  13834. * | 1 | BILLBOARDMODE_X | |
  13835. * | 2 | BILLBOARDMODE_Y | |
  13836. * | 4 | BILLBOARDMODE_Z | |
  13837. * | 7 | BILLBOARDMODE_ALL | |
  13838. *
  13839. */
  13840. billboardMode: number;
  13841. private _preserveParentRotationForBillboard;
  13842. /**
  13843. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13844. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13845. */
  13846. preserveParentRotationForBillboard: boolean;
  13847. /**
  13848. * 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
  13849. */
  13850. scalingDeterminant: number;
  13851. private _infiniteDistance;
  13852. /**
  13853. * Gets or sets the distance of the object to max, often used by skybox
  13854. */
  13855. infiniteDistance: boolean;
  13856. /**
  13857. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13858. * By default the system will update normals to compensate
  13859. */
  13860. ignoreNonUniformScaling: boolean;
  13861. /**
  13862. * 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
  13863. */
  13864. reIntegrateRotationIntoRotationQuaternion: boolean;
  13865. /** @hidden */
  13866. _poseMatrix: Nullable<Matrix>;
  13867. /** @hidden */
  13868. _localMatrix: Matrix;
  13869. private _usePivotMatrix;
  13870. private _absolutePosition;
  13871. private _absoluteScaling;
  13872. private _absoluteRotationQuaternion;
  13873. private _pivotMatrix;
  13874. private _pivotMatrixInverse;
  13875. protected _postMultiplyPivotMatrix: boolean;
  13876. protected _isWorldMatrixFrozen: boolean;
  13877. /** @hidden */
  13878. _indexInSceneTransformNodesArray: number;
  13879. /**
  13880. * An event triggered after the world matrix is updated
  13881. */
  13882. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13883. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13884. /**
  13885. * Gets a string identifying the name of the class
  13886. * @returns "TransformNode" string
  13887. */
  13888. getClassName(): string;
  13889. /**
  13890. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13891. */
  13892. position: Vector3;
  13893. /**
  13894. * 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)).
  13895. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13896. */
  13897. rotation: Vector3;
  13898. /**
  13899. * 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)).
  13900. */
  13901. scaling: Vector3;
  13902. /**
  13903. * 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).
  13904. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13905. */
  13906. rotationQuaternion: Nullable<Quaternion>;
  13907. /**
  13908. * The forward direction of that transform in world space.
  13909. */
  13910. readonly forward: Vector3;
  13911. /**
  13912. * The up direction of that transform in world space.
  13913. */
  13914. readonly up: Vector3;
  13915. /**
  13916. * The right direction of that transform in world space.
  13917. */
  13918. readonly right: Vector3;
  13919. /**
  13920. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13921. * @param matrix the matrix to copy the pose from
  13922. * @returns this TransformNode.
  13923. */
  13924. updatePoseMatrix(matrix: Matrix): TransformNode;
  13925. /**
  13926. * Returns the mesh Pose matrix.
  13927. * @returns the pose matrix
  13928. */
  13929. getPoseMatrix(): Matrix;
  13930. /** @hidden */
  13931. _isSynchronized(): boolean;
  13932. /** @hidden */
  13933. _initCache(): void;
  13934. /**
  13935. * Flag the transform node as dirty (Forcing it to update everything)
  13936. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13937. * @returns this transform node
  13938. */
  13939. markAsDirty(property: string): TransformNode;
  13940. /**
  13941. * Returns the current mesh absolute position.
  13942. * Returns a Vector3.
  13943. */
  13944. readonly absolutePosition: Vector3;
  13945. /**
  13946. * Returns the current mesh absolute scaling.
  13947. * Returns a Vector3.
  13948. */
  13949. readonly absoluteScaling: Vector3;
  13950. /**
  13951. * Returns the current mesh absolute rotation.
  13952. * Returns a Quaternion.
  13953. */
  13954. readonly absoluteRotationQuaternion: Quaternion;
  13955. /**
  13956. * Sets a new matrix to apply before all other transformation
  13957. * @param matrix defines the transform matrix
  13958. * @returns the current TransformNode
  13959. */
  13960. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13961. /**
  13962. * Sets a new pivot matrix to the current node
  13963. * @param matrix defines the new pivot matrix to use
  13964. * @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
  13965. * @returns the current TransformNode
  13966. */
  13967. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13968. /**
  13969. * Returns the mesh pivot matrix.
  13970. * Default : Identity.
  13971. * @returns the matrix
  13972. */
  13973. getPivotMatrix(): Matrix;
  13974. /**
  13975. * Instantiate (when possible) or clone that node with its hierarchy
  13976. * @param newParent defines the new parent to use for the instance (or clone)
  13977. * @returns an instance (or a clone) of the current node with its hiearchy
  13978. */
  13979. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13980. /**
  13981. * Prevents the World matrix to be computed any longer
  13982. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13983. * @returns the TransformNode.
  13984. */
  13985. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13986. /**
  13987. * Allows back the World matrix computation.
  13988. * @returns the TransformNode.
  13989. */
  13990. unfreezeWorldMatrix(): this;
  13991. /**
  13992. * True if the World matrix has been frozen.
  13993. */
  13994. readonly isWorldMatrixFrozen: boolean;
  13995. /**
  13996. * Retuns the mesh absolute position in the World.
  13997. * @returns a Vector3.
  13998. */
  13999. getAbsolutePosition(): Vector3;
  14000. /**
  14001. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14002. * @param absolutePosition the absolute position to set
  14003. * @returns the TransformNode.
  14004. */
  14005. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14006. /**
  14007. * Sets the mesh position in its local space.
  14008. * @param vector3 the position to set in localspace
  14009. * @returns the TransformNode.
  14010. */
  14011. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14012. /**
  14013. * Returns the mesh position in the local space from the current World matrix values.
  14014. * @returns a new Vector3.
  14015. */
  14016. getPositionExpressedInLocalSpace(): Vector3;
  14017. /**
  14018. * Translates the mesh along the passed Vector3 in its local space.
  14019. * @param vector3 the distance to translate in localspace
  14020. * @returns the TransformNode.
  14021. */
  14022. locallyTranslate(vector3: Vector3): TransformNode;
  14023. private static _lookAtVectorCache;
  14024. /**
  14025. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14026. * @param targetPoint the position (must be in same space as current mesh) to look at
  14027. * @param yawCor optional yaw (y-axis) correction in radians
  14028. * @param pitchCor optional pitch (x-axis) correction in radians
  14029. * @param rollCor optional roll (z-axis) correction in radians
  14030. * @param space the choosen space of the target
  14031. * @returns the TransformNode.
  14032. */
  14033. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14034. /**
  14035. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14036. * This Vector3 is expressed in the World space.
  14037. * @param localAxis axis to rotate
  14038. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14039. */
  14040. getDirection(localAxis: Vector3): Vector3;
  14041. /**
  14042. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14043. * localAxis is expressed in the mesh local space.
  14044. * result is computed in the Wordl space from the mesh World matrix.
  14045. * @param localAxis axis to rotate
  14046. * @param result the resulting transformnode
  14047. * @returns this TransformNode.
  14048. */
  14049. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14050. /**
  14051. * Sets this transform node rotation to the given local axis.
  14052. * @param localAxis the axis in local space
  14053. * @param yawCor optional yaw (y-axis) correction in radians
  14054. * @param pitchCor optional pitch (x-axis) correction in radians
  14055. * @param rollCor optional roll (z-axis) correction in radians
  14056. * @returns this TransformNode
  14057. */
  14058. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14059. /**
  14060. * Sets a new pivot point to the current node
  14061. * @param point defines the new pivot point to use
  14062. * @param space defines if the point is in world or local space (local by default)
  14063. * @returns the current TransformNode
  14064. */
  14065. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14066. /**
  14067. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14068. * @returns the pivot point
  14069. */
  14070. getPivotPoint(): Vector3;
  14071. /**
  14072. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14073. * @param result the vector3 to store the result
  14074. * @returns this TransformNode.
  14075. */
  14076. getPivotPointToRef(result: Vector3): TransformNode;
  14077. /**
  14078. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14079. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14080. */
  14081. getAbsolutePivotPoint(): Vector3;
  14082. /**
  14083. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14084. * @param result vector3 to store the result
  14085. * @returns this TransformNode.
  14086. */
  14087. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14088. /**
  14089. * Defines the passed node as the parent of the current node.
  14090. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14091. * @see https://doc.babylonjs.com/how_to/parenting
  14092. * @param node the node ot set as the parent
  14093. * @returns this TransformNode.
  14094. */
  14095. setParent(node: Nullable<Node>): TransformNode;
  14096. private _nonUniformScaling;
  14097. /**
  14098. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14099. */
  14100. readonly nonUniformScaling: boolean;
  14101. /** @hidden */
  14102. _updateNonUniformScalingState(value: boolean): boolean;
  14103. /**
  14104. * Attach the current TransformNode to another TransformNode associated with a bone
  14105. * @param bone Bone affecting the TransformNode
  14106. * @param affectedTransformNode TransformNode associated with the bone
  14107. * @returns this object
  14108. */
  14109. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14110. /**
  14111. * Detach the transform node if its associated with a bone
  14112. * @returns this object
  14113. */
  14114. detachFromBone(): TransformNode;
  14115. private static _rotationAxisCache;
  14116. /**
  14117. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14118. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14119. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14120. * The passed axis is also normalized.
  14121. * @param axis the axis to rotate around
  14122. * @param amount the amount to rotate in radians
  14123. * @param space Space to rotate in (Default: local)
  14124. * @returns the TransformNode.
  14125. */
  14126. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14127. /**
  14128. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14129. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14130. * The passed axis is also normalized. .
  14131. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14132. * @param point the point to rotate around
  14133. * @param axis the axis to rotate around
  14134. * @param amount the amount to rotate in radians
  14135. * @returns the TransformNode
  14136. */
  14137. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14138. /**
  14139. * Translates the mesh along the axis vector for the passed distance in the given space.
  14140. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14141. * @param axis the axis to translate in
  14142. * @param distance the distance to translate
  14143. * @param space Space to rotate in (Default: local)
  14144. * @returns the TransformNode.
  14145. */
  14146. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14147. /**
  14148. * Adds a rotation step to the mesh current rotation.
  14149. * x, y, z are Euler angles expressed in radians.
  14150. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14151. * This means this rotation is made in the mesh local space only.
  14152. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14153. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14154. * ```javascript
  14155. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14156. * ```
  14157. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14158. * 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.
  14159. * @param x Rotation to add
  14160. * @param y Rotation to add
  14161. * @param z Rotation to add
  14162. * @returns the TransformNode.
  14163. */
  14164. addRotation(x: number, y: number, z: number): TransformNode;
  14165. /**
  14166. * @hidden
  14167. */
  14168. protected _getEffectiveParent(): Nullable<Node>;
  14169. /**
  14170. * Computes the world matrix of the node
  14171. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14172. * @returns the world matrix
  14173. */
  14174. computeWorldMatrix(force?: boolean): Matrix;
  14175. protected _afterComputeWorldMatrix(): void;
  14176. /**
  14177. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14178. * @param func callback function to add
  14179. *
  14180. * @returns the TransformNode.
  14181. */
  14182. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14183. /**
  14184. * Removes a registered callback function.
  14185. * @param func callback function to remove
  14186. * @returns the TransformNode.
  14187. */
  14188. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14189. /**
  14190. * Gets the position of the current mesh in camera space
  14191. * @param camera defines the camera to use
  14192. * @returns a position
  14193. */
  14194. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14195. /**
  14196. * Returns the distance from the mesh to the active camera
  14197. * @param camera defines the camera to use
  14198. * @returns the distance
  14199. */
  14200. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14201. /**
  14202. * Clone the current transform node
  14203. * @param name Name of the new clone
  14204. * @param newParent New parent for the clone
  14205. * @param doNotCloneChildren Do not clone children hierarchy
  14206. * @returns the new transform node
  14207. */
  14208. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14209. /**
  14210. * Serializes the objects information.
  14211. * @param currentSerializationObject defines the object to serialize in
  14212. * @returns the serialized object
  14213. */
  14214. serialize(currentSerializationObject?: any): any;
  14215. /**
  14216. * Returns a new TransformNode object parsed from the source provided.
  14217. * @param parsedTransformNode is the source.
  14218. * @param scene the scne the object belongs to
  14219. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14220. * @returns a new TransformNode object parsed from the source provided.
  14221. */
  14222. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14223. /**
  14224. * Get all child-transformNodes of this node
  14225. * @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
  14226. * @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
  14227. * @returns an array of TransformNode
  14228. */
  14229. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14230. /**
  14231. * Releases resources associated with this transform node.
  14232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14234. */
  14235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14236. /**
  14237. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14238. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14239. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14240. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14241. * @returns the current mesh
  14242. */
  14243. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14244. private _syncAbsoluteScalingAndRotation;
  14245. }
  14246. }
  14247. declare module BABYLON {
  14248. /**
  14249. * Defines the types of pose enabled controllers that are supported
  14250. */
  14251. export enum PoseEnabledControllerType {
  14252. /**
  14253. * HTC Vive
  14254. */
  14255. VIVE = 0,
  14256. /**
  14257. * Oculus Rift
  14258. */
  14259. OCULUS = 1,
  14260. /**
  14261. * Windows mixed reality
  14262. */
  14263. WINDOWS = 2,
  14264. /**
  14265. * Samsung gear VR
  14266. */
  14267. GEAR_VR = 3,
  14268. /**
  14269. * Google Daydream
  14270. */
  14271. DAYDREAM = 4,
  14272. /**
  14273. * Generic
  14274. */
  14275. GENERIC = 5
  14276. }
  14277. /**
  14278. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14279. */
  14280. export interface MutableGamepadButton {
  14281. /**
  14282. * Value of the button/trigger
  14283. */
  14284. value: number;
  14285. /**
  14286. * If the button/trigger is currently touched
  14287. */
  14288. touched: boolean;
  14289. /**
  14290. * If the button/trigger is currently pressed
  14291. */
  14292. pressed: boolean;
  14293. }
  14294. /**
  14295. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14296. * @hidden
  14297. */
  14298. export interface ExtendedGamepadButton extends GamepadButton {
  14299. /**
  14300. * If the button/trigger is currently pressed
  14301. */
  14302. readonly pressed: boolean;
  14303. /**
  14304. * If the button/trigger is currently touched
  14305. */
  14306. readonly touched: boolean;
  14307. /**
  14308. * Value of the button/trigger
  14309. */
  14310. readonly value: number;
  14311. }
  14312. /** @hidden */
  14313. export interface _GamePadFactory {
  14314. /**
  14315. * Returns wether or not the current gamepad can be created for this type of controller.
  14316. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14317. * @returns true if it can be created, otherwise false
  14318. */
  14319. canCreate(gamepadInfo: any): boolean;
  14320. /**
  14321. * Creates a new instance of the Gamepad.
  14322. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14323. * @returns the new gamepad instance
  14324. */
  14325. create(gamepadInfo: any): Gamepad;
  14326. }
  14327. /**
  14328. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14329. */
  14330. export class PoseEnabledControllerHelper {
  14331. /** @hidden */
  14332. static _ControllerFactories: _GamePadFactory[];
  14333. /** @hidden */
  14334. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14335. /**
  14336. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14337. * @param vrGamepad the gamepad to initialized
  14338. * @returns a vr controller of the type the gamepad identified as
  14339. */
  14340. static InitiateController(vrGamepad: any): Gamepad;
  14341. }
  14342. /**
  14343. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14344. */
  14345. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14346. /**
  14347. * If the controller is used in a webXR session
  14348. */
  14349. isXR: boolean;
  14350. private _deviceRoomPosition;
  14351. private _deviceRoomRotationQuaternion;
  14352. /**
  14353. * The device position in babylon space
  14354. */
  14355. devicePosition: Vector3;
  14356. /**
  14357. * The device rotation in babylon space
  14358. */
  14359. deviceRotationQuaternion: Quaternion;
  14360. /**
  14361. * The scale factor of the device in babylon space
  14362. */
  14363. deviceScaleFactor: number;
  14364. /**
  14365. * (Likely devicePosition should be used instead) The device position in its room space
  14366. */
  14367. position: Vector3;
  14368. /**
  14369. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14370. */
  14371. rotationQuaternion: Quaternion;
  14372. /**
  14373. * The type of controller (Eg. Windows mixed reality)
  14374. */
  14375. controllerType: PoseEnabledControllerType;
  14376. protected _calculatedPosition: Vector3;
  14377. private _calculatedRotation;
  14378. /**
  14379. * The raw pose from the device
  14380. */
  14381. rawPose: DevicePose;
  14382. private _trackPosition;
  14383. private _maxRotationDistFromHeadset;
  14384. private _draggedRoomRotation;
  14385. /**
  14386. * @hidden
  14387. */
  14388. _disableTrackPosition(fixedPosition: Vector3): void;
  14389. /**
  14390. * Internal, the mesh attached to the controller
  14391. * @hidden
  14392. */
  14393. _mesh: Nullable<AbstractMesh>;
  14394. private _poseControlledCamera;
  14395. private _leftHandSystemQuaternion;
  14396. /**
  14397. * Internal, matrix used to convert room space to babylon space
  14398. * @hidden
  14399. */
  14400. _deviceToWorld: Matrix;
  14401. /**
  14402. * Node to be used when casting a ray from the controller
  14403. * @hidden
  14404. */
  14405. _pointingPoseNode: Nullable<TransformNode>;
  14406. /**
  14407. * Name of the child mesh that can be used to cast a ray from the controller
  14408. */
  14409. static readonly POINTING_POSE: string;
  14410. /**
  14411. * Creates a new PoseEnabledController from a gamepad
  14412. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14413. */
  14414. constructor(browserGamepad: any);
  14415. private _workingMatrix;
  14416. /**
  14417. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14418. */
  14419. update(): void;
  14420. /**
  14421. * Updates only the pose device and mesh without doing any button event checking
  14422. */
  14423. protected _updatePoseAndMesh(): void;
  14424. /**
  14425. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14426. * @param poseData raw pose fromthe device
  14427. */
  14428. updateFromDevice(poseData: DevicePose): void;
  14429. /**
  14430. * @hidden
  14431. */
  14432. _meshAttachedObservable: Observable<AbstractMesh>;
  14433. /**
  14434. * Attaches a mesh to the controller
  14435. * @param mesh the mesh to be attached
  14436. */
  14437. attachToMesh(mesh: AbstractMesh): void;
  14438. /**
  14439. * Attaches the controllers mesh to a camera
  14440. * @param camera the camera the mesh should be attached to
  14441. */
  14442. attachToPoseControlledCamera(camera: TargetCamera): void;
  14443. /**
  14444. * Disposes of the controller
  14445. */
  14446. dispose(): void;
  14447. /**
  14448. * The mesh that is attached to the controller
  14449. */
  14450. readonly mesh: Nullable<AbstractMesh>;
  14451. /**
  14452. * Gets the ray of the controller in the direction the controller is pointing
  14453. * @param length the length the resulting ray should be
  14454. * @returns a ray in the direction the controller is pointing
  14455. */
  14456. getForwardRay(length?: number): Ray;
  14457. }
  14458. }
  14459. declare module BABYLON {
  14460. /**
  14461. * Defines the WebVRController object that represents controllers tracked in 3D space
  14462. */
  14463. export abstract class WebVRController extends PoseEnabledController {
  14464. /**
  14465. * Internal, the default controller model for the controller
  14466. */
  14467. protected _defaultModel: Nullable<AbstractMesh>;
  14468. /**
  14469. * Fired when the trigger state has changed
  14470. */
  14471. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14472. /**
  14473. * Fired when the main button state has changed
  14474. */
  14475. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14476. /**
  14477. * Fired when the secondary button state has changed
  14478. */
  14479. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14480. /**
  14481. * Fired when the pad state has changed
  14482. */
  14483. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14484. /**
  14485. * Fired when controllers stick values have changed
  14486. */
  14487. onPadValuesChangedObservable: Observable<StickValues>;
  14488. /**
  14489. * Array of button availible on the controller
  14490. */
  14491. protected _buttons: Array<MutableGamepadButton>;
  14492. private _onButtonStateChange;
  14493. /**
  14494. * Fired when a controller button's state has changed
  14495. * @param callback the callback containing the button that was modified
  14496. */
  14497. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14498. /**
  14499. * X and Y axis corresponding to the controllers joystick
  14500. */
  14501. pad: StickValues;
  14502. /**
  14503. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14504. */
  14505. hand: string;
  14506. /**
  14507. * The default controller model for the controller
  14508. */
  14509. readonly defaultModel: Nullable<AbstractMesh>;
  14510. /**
  14511. * Creates a new WebVRController from a gamepad
  14512. * @param vrGamepad the gamepad that the WebVRController should be created from
  14513. */
  14514. constructor(vrGamepad: any);
  14515. /**
  14516. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14517. */
  14518. update(): void;
  14519. /**
  14520. * Function to be called when a button is modified
  14521. */
  14522. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14523. /**
  14524. * Loads a mesh and attaches it to the controller
  14525. * @param scene the scene the mesh should be added to
  14526. * @param meshLoaded callback for when the mesh has been loaded
  14527. */
  14528. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14529. private _setButtonValue;
  14530. private _changes;
  14531. private _checkChanges;
  14532. /**
  14533. * Disposes of th webVRCOntroller
  14534. */
  14535. dispose(): void;
  14536. }
  14537. }
  14538. declare module BABYLON {
  14539. /**
  14540. * The HemisphericLight simulates the ambient environment light,
  14541. * so the passed direction is the light reflection direction, not the incoming direction.
  14542. */
  14543. export class HemisphericLight extends Light {
  14544. /**
  14545. * The groundColor is the light in the opposite direction to the one specified during creation.
  14546. * 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.
  14547. */
  14548. groundColor: Color3;
  14549. /**
  14550. * The light reflection direction, not the incoming direction.
  14551. */
  14552. direction: Vector3;
  14553. /**
  14554. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14555. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14556. * The HemisphericLight can't cast shadows.
  14557. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14558. * @param name The friendly name of the light
  14559. * @param direction The direction of the light reflection
  14560. * @param scene The scene the light belongs to
  14561. */
  14562. constructor(name: string, direction: Vector3, scene: Scene);
  14563. protected _buildUniformLayout(): void;
  14564. /**
  14565. * Returns the string "HemisphericLight".
  14566. * @return The class name
  14567. */
  14568. getClassName(): string;
  14569. /**
  14570. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14571. * Returns the updated direction.
  14572. * @param target The target the direction should point to
  14573. * @return The computed direction
  14574. */
  14575. setDirectionToTarget(target: Vector3): Vector3;
  14576. /**
  14577. * Returns the shadow generator associated to the light.
  14578. * @returns Always null for hemispheric lights because it does not support shadows.
  14579. */
  14580. getShadowGenerator(): Nullable<IShadowGenerator>;
  14581. /**
  14582. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14583. * @param effect The effect to update
  14584. * @param lightIndex The index of the light in the effect to update
  14585. * @returns The hemispheric light
  14586. */
  14587. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14588. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14589. /**
  14590. * Computes the world matrix of the node
  14591. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14592. * @param useWasUpdatedFlag defines a reserved property
  14593. * @returns the world matrix
  14594. */
  14595. computeWorldMatrix(): Matrix;
  14596. /**
  14597. * Returns the integer 3.
  14598. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14599. */
  14600. getTypeID(): number;
  14601. /**
  14602. * Prepares the list of defines specific to the light type.
  14603. * @param defines the list of defines
  14604. * @param lightIndex defines the index of the light for the effect
  14605. */
  14606. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14607. }
  14608. }
  14609. declare module BABYLON {
  14610. /** @hidden */
  14611. export var vrMultiviewToSingleviewPixelShader: {
  14612. name: string;
  14613. shader: string;
  14614. };
  14615. }
  14616. declare module BABYLON {
  14617. /**
  14618. * Renders to multiple views with a single draw call
  14619. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14620. */
  14621. export class MultiviewRenderTarget extends RenderTargetTexture {
  14622. /**
  14623. * Creates a multiview render target
  14624. * @param scene scene used with the render target
  14625. * @param size the size of the render target (used for each view)
  14626. */
  14627. constructor(scene: Scene, size?: number | {
  14628. width: number;
  14629. height: number;
  14630. } | {
  14631. ratio: number;
  14632. });
  14633. /**
  14634. * @hidden
  14635. * @param faceIndex the face index, if its a cube texture
  14636. */
  14637. _bindFrameBuffer(faceIndex?: number): void;
  14638. /**
  14639. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14640. * @returns the view count
  14641. */
  14642. getViewCount(): number;
  14643. }
  14644. }
  14645. declare module BABYLON {
  14646. /**
  14647. * Represents a camera frustum
  14648. */
  14649. export class Frustum {
  14650. /**
  14651. * Gets the planes representing the frustum
  14652. * @param transform matrix to be applied to the returned planes
  14653. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14654. */
  14655. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14656. /**
  14657. * Gets the near frustum plane transformed by the transform matrix
  14658. * @param transform transformation matrix to be applied to the resulting frustum plane
  14659. * @param frustumPlane the resuling frustum plane
  14660. */
  14661. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14662. /**
  14663. * Gets the far frustum plane transformed by the transform matrix
  14664. * @param transform transformation matrix to be applied to the resulting frustum plane
  14665. * @param frustumPlane the resuling frustum plane
  14666. */
  14667. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14668. /**
  14669. * Gets the left frustum plane transformed by the transform matrix
  14670. * @param transform transformation matrix to be applied to the resulting frustum plane
  14671. * @param frustumPlane the resuling frustum plane
  14672. */
  14673. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14674. /**
  14675. * Gets the right frustum plane transformed by the transform matrix
  14676. * @param transform transformation matrix to be applied to the resulting frustum plane
  14677. * @param frustumPlane the resuling frustum plane
  14678. */
  14679. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14680. /**
  14681. * Gets the top frustum plane transformed by the transform matrix
  14682. * @param transform transformation matrix to be applied to the resulting frustum plane
  14683. * @param frustumPlane the resuling frustum plane
  14684. */
  14685. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14686. /**
  14687. * Gets the bottom frustum plane transformed by the transform matrix
  14688. * @param transform transformation matrix to be applied to the resulting frustum plane
  14689. * @param frustumPlane the resuling frustum plane
  14690. */
  14691. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14692. /**
  14693. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14694. * @param transform transformation matrix to be applied to the resulting frustum planes
  14695. * @param frustumPlanes the resuling frustum planes
  14696. */
  14697. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14698. }
  14699. }
  14700. declare module BABYLON {
  14701. interface Engine {
  14702. /**
  14703. * Creates a new multiview render target
  14704. * @param width defines the width of the texture
  14705. * @param height defines the height of the texture
  14706. * @returns the created multiview texture
  14707. */
  14708. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14709. /**
  14710. * Binds a multiview framebuffer to be drawn to
  14711. * @param multiviewTexture texture to bind
  14712. */
  14713. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14714. }
  14715. interface Camera {
  14716. /**
  14717. * @hidden
  14718. * 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)
  14719. */
  14720. _useMultiviewToSingleView: boolean;
  14721. /**
  14722. * @hidden
  14723. * 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)
  14724. */
  14725. _multiviewTexture: Nullable<RenderTargetTexture>;
  14726. /**
  14727. * @hidden
  14728. * ensures the multiview texture of the camera exists and has the specified width/height
  14729. * @param width height to set on the multiview texture
  14730. * @param height width to set on the multiview texture
  14731. */
  14732. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14733. }
  14734. interface Scene {
  14735. /** @hidden */
  14736. _transformMatrixR: Matrix;
  14737. /** @hidden */
  14738. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14739. /** @hidden */
  14740. _createMultiviewUbo(): void;
  14741. /** @hidden */
  14742. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14743. /** @hidden */
  14744. _renderMultiviewToSingleView(camera: Camera): void;
  14745. }
  14746. }
  14747. declare module BABYLON {
  14748. /**
  14749. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14750. * This will not be used for webXR as it supports displaying texture arrays directly
  14751. */
  14752. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14753. /**
  14754. * Initializes a VRMultiviewToSingleview
  14755. * @param name name of the post process
  14756. * @param camera camera to be applied to
  14757. * @param scaleFactor scaling factor to the size of the output texture
  14758. */
  14759. constructor(name: string, camera: Camera, scaleFactor: number);
  14760. }
  14761. }
  14762. declare module BABYLON {
  14763. interface Engine {
  14764. /** @hidden */
  14765. _vrDisplay: any;
  14766. /** @hidden */
  14767. _vrSupported: boolean;
  14768. /** @hidden */
  14769. _oldSize: Size;
  14770. /** @hidden */
  14771. _oldHardwareScaleFactor: number;
  14772. /** @hidden */
  14773. _vrExclusivePointerMode: boolean;
  14774. /** @hidden */
  14775. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14776. /** @hidden */
  14777. _onVRDisplayPointerRestricted: () => void;
  14778. /** @hidden */
  14779. _onVRDisplayPointerUnrestricted: () => void;
  14780. /** @hidden */
  14781. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14782. /** @hidden */
  14783. _onVrDisplayDisconnect: Nullable<() => void>;
  14784. /** @hidden */
  14785. _onVrDisplayPresentChange: Nullable<() => void>;
  14786. /**
  14787. * Observable signaled when VR display mode changes
  14788. */
  14789. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14790. /**
  14791. * Observable signaled when VR request present is complete
  14792. */
  14793. onVRRequestPresentComplete: Observable<boolean>;
  14794. /**
  14795. * Observable signaled when VR request present starts
  14796. */
  14797. onVRRequestPresentStart: Observable<Engine>;
  14798. /**
  14799. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14800. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14801. */
  14802. isInVRExclusivePointerMode: boolean;
  14803. /**
  14804. * Gets a boolean indicating if a webVR device was detected
  14805. * @returns true if a webVR device was detected
  14806. */
  14807. isVRDevicePresent(): boolean;
  14808. /**
  14809. * Gets the current webVR device
  14810. * @returns the current webVR device (or null)
  14811. */
  14812. getVRDevice(): any;
  14813. /**
  14814. * Initializes a webVR display and starts listening to display change events
  14815. * The onVRDisplayChangedObservable will be notified upon these changes
  14816. * @returns A promise containing a VRDisplay and if vr is supported
  14817. */
  14818. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14819. /** @hidden */
  14820. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14821. /**
  14822. * Call this function to switch to webVR mode
  14823. * Will do nothing if webVR is not supported or if there is no webVR device
  14824. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14825. */
  14826. enableVR(): void;
  14827. /** @hidden */
  14828. _onVRFullScreenTriggered(): void;
  14829. }
  14830. }
  14831. declare module BABYLON {
  14832. /**
  14833. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14834. * IMPORTANT!! The data is right-hand data.
  14835. * @export
  14836. * @interface DevicePose
  14837. */
  14838. export interface DevicePose {
  14839. /**
  14840. * The position of the device, values in array are [x,y,z].
  14841. */
  14842. readonly position: Nullable<Float32Array>;
  14843. /**
  14844. * The linearVelocity of the device, values in array are [x,y,z].
  14845. */
  14846. readonly linearVelocity: Nullable<Float32Array>;
  14847. /**
  14848. * The linearAcceleration of the device, values in array are [x,y,z].
  14849. */
  14850. readonly linearAcceleration: Nullable<Float32Array>;
  14851. /**
  14852. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14853. */
  14854. readonly orientation: Nullable<Float32Array>;
  14855. /**
  14856. * The angularVelocity of the device, values in array are [x,y,z].
  14857. */
  14858. readonly angularVelocity: Nullable<Float32Array>;
  14859. /**
  14860. * The angularAcceleration of the device, values in array are [x,y,z].
  14861. */
  14862. readonly angularAcceleration: Nullable<Float32Array>;
  14863. }
  14864. /**
  14865. * Interface representing a pose controlled object in Babylon.
  14866. * A pose controlled object has both regular pose values as well as pose values
  14867. * from an external device such as a VR head mounted display
  14868. */
  14869. export interface PoseControlled {
  14870. /**
  14871. * The position of the object in babylon space.
  14872. */
  14873. position: Vector3;
  14874. /**
  14875. * The rotation quaternion of the object in babylon space.
  14876. */
  14877. rotationQuaternion: Quaternion;
  14878. /**
  14879. * The position of the device in babylon space.
  14880. */
  14881. devicePosition?: Vector3;
  14882. /**
  14883. * The rotation quaternion of the device in babylon space.
  14884. */
  14885. deviceRotationQuaternion: Quaternion;
  14886. /**
  14887. * The raw pose coming from the device.
  14888. */
  14889. rawPose: Nullable<DevicePose>;
  14890. /**
  14891. * The scale of the device to be used when translating from device space to babylon space.
  14892. */
  14893. deviceScaleFactor: number;
  14894. /**
  14895. * Updates the poseControlled values based on the input device pose.
  14896. * @param poseData the pose data to update the object with
  14897. */
  14898. updateFromDevice(poseData: DevicePose): void;
  14899. }
  14900. /**
  14901. * Set of options to customize the webVRCamera
  14902. */
  14903. export interface WebVROptions {
  14904. /**
  14905. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14906. */
  14907. trackPosition?: boolean;
  14908. /**
  14909. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14910. */
  14911. positionScale?: number;
  14912. /**
  14913. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14914. */
  14915. displayName?: string;
  14916. /**
  14917. * Should the native controller meshes be initialized. (default: true)
  14918. */
  14919. controllerMeshes?: boolean;
  14920. /**
  14921. * Creating a default HemiLight only on controllers. (default: true)
  14922. */
  14923. defaultLightingOnControllers?: boolean;
  14924. /**
  14925. * If you don't want to use the default VR button of the helper. (default: false)
  14926. */
  14927. useCustomVRButton?: boolean;
  14928. /**
  14929. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14930. */
  14931. customVRButton?: HTMLButtonElement;
  14932. /**
  14933. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14934. */
  14935. rayLength?: number;
  14936. /**
  14937. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14938. */
  14939. defaultHeight?: number;
  14940. /**
  14941. * If multiview should be used if availible (default: false)
  14942. */
  14943. useMultiview?: boolean;
  14944. }
  14945. /**
  14946. * This represents a WebVR camera.
  14947. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14948. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14949. */
  14950. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14951. private webVROptions;
  14952. /**
  14953. * @hidden
  14954. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14955. */
  14956. _vrDevice: any;
  14957. /**
  14958. * The rawPose of the vrDevice.
  14959. */
  14960. rawPose: Nullable<DevicePose>;
  14961. private _onVREnabled;
  14962. private _specsVersion;
  14963. private _attached;
  14964. private _frameData;
  14965. protected _descendants: Array<Node>;
  14966. private _deviceRoomPosition;
  14967. /** @hidden */
  14968. _deviceRoomRotationQuaternion: Quaternion;
  14969. private _standingMatrix;
  14970. /**
  14971. * Represents device position in babylon space.
  14972. */
  14973. devicePosition: Vector3;
  14974. /**
  14975. * Represents device rotation in babylon space.
  14976. */
  14977. deviceRotationQuaternion: Quaternion;
  14978. /**
  14979. * The scale of the device to be used when translating from device space to babylon space.
  14980. */
  14981. deviceScaleFactor: number;
  14982. private _deviceToWorld;
  14983. private _worldToDevice;
  14984. /**
  14985. * References to the webVR controllers for the vrDevice.
  14986. */
  14987. controllers: Array<WebVRController>;
  14988. /**
  14989. * Emits an event when a controller is attached.
  14990. */
  14991. onControllersAttachedObservable: Observable<WebVRController[]>;
  14992. /**
  14993. * Emits an event when a controller's mesh has been loaded;
  14994. */
  14995. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14996. /**
  14997. * Emits an event when the HMD's pose has been updated.
  14998. */
  14999. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15000. private _poseSet;
  15001. /**
  15002. * If the rig cameras be used as parent instead of this camera.
  15003. */
  15004. rigParenting: boolean;
  15005. private _lightOnControllers;
  15006. private _defaultHeight?;
  15007. /**
  15008. * Instantiates a WebVRFreeCamera.
  15009. * @param name The name of the WebVRFreeCamera
  15010. * @param position The starting anchor position for the camera
  15011. * @param scene The scene the camera belongs to
  15012. * @param webVROptions a set of customizable options for the webVRCamera
  15013. */
  15014. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15015. /**
  15016. * Gets the device distance from the ground in meters.
  15017. * @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.
  15018. */
  15019. deviceDistanceToRoomGround(): number;
  15020. /**
  15021. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15022. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15023. */
  15024. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15025. /**
  15026. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15027. * @returns A promise with a boolean set to if the standing matrix is supported.
  15028. */
  15029. useStandingMatrixAsync(): Promise<boolean>;
  15030. /**
  15031. * Disposes the camera
  15032. */
  15033. dispose(): void;
  15034. /**
  15035. * Gets a vrController by name.
  15036. * @param name The name of the controller to retreive
  15037. * @returns the controller matching the name specified or null if not found
  15038. */
  15039. getControllerByName(name: string): Nullable<WebVRController>;
  15040. private _leftController;
  15041. /**
  15042. * The controller corresponding to the users left hand.
  15043. */
  15044. readonly leftController: Nullable<WebVRController>;
  15045. private _rightController;
  15046. /**
  15047. * The controller corresponding to the users right hand.
  15048. */
  15049. readonly rightController: Nullable<WebVRController>;
  15050. /**
  15051. * Casts a ray forward from the vrCamera's gaze.
  15052. * @param length Length of the ray (default: 100)
  15053. * @returns the ray corresponding to the gaze
  15054. */
  15055. getForwardRay(length?: number): Ray;
  15056. /**
  15057. * @hidden
  15058. * Updates the camera based on device's frame data
  15059. */
  15060. _checkInputs(): void;
  15061. /**
  15062. * Updates the poseControlled values based on the input device pose.
  15063. * @param poseData Pose coming from the device
  15064. */
  15065. updateFromDevice(poseData: DevicePose): void;
  15066. private _htmlElementAttached;
  15067. private _detachIfAttached;
  15068. /**
  15069. * WebVR's attach control will start broadcasting frames to the device.
  15070. * Note that in certain browsers (chrome for example) this function must be called
  15071. * within a user-interaction callback. Example:
  15072. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15073. *
  15074. * @param element html element to attach the vrDevice to
  15075. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15076. */
  15077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15078. /**
  15079. * Detaches the camera from the html element and disables VR
  15080. *
  15081. * @param element html element to detach from
  15082. */
  15083. detachControl(element: HTMLElement): void;
  15084. /**
  15085. * @returns the name of this class
  15086. */
  15087. getClassName(): string;
  15088. /**
  15089. * Calls resetPose on the vrDisplay
  15090. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15091. */
  15092. resetToCurrentRotation(): void;
  15093. /**
  15094. * @hidden
  15095. * Updates the rig cameras (left and right eye)
  15096. */
  15097. _updateRigCameras(): void;
  15098. private _workingVector;
  15099. private _oneVector;
  15100. private _workingMatrix;
  15101. private updateCacheCalled;
  15102. private _correctPositionIfNotTrackPosition;
  15103. /**
  15104. * @hidden
  15105. * Updates the cached values of the camera
  15106. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15107. */
  15108. _updateCache(ignoreParentClass?: boolean): void;
  15109. /**
  15110. * @hidden
  15111. * Get current device position in babylon world
  15112. */
  15113. _computeDevicePosition(): void;
  15114. /**
  15115. * Updates the current device position and rotation in the babylon world
  15116. */
  15117. update(): void;
  15118. /**
  15119. * @hidden
  15120. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15121. * @returns an identity matrix
  15122. */
  15123. _getViewMatrix(): Matrix;
  15124. private _tmpMatrix;
  15125. /**
  15126. * This function is called by the two RIG cameras.
  15127. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15128. * @hidden
  15129. */
  15130. _getWebVRViewMatrix(): Matrix;
  15131. /** @hidden */
  15132. _getWebVRProjectionMatrix(): Matrix;
  15133. private _onGamepadConnectedObserver;
  15134. private _onGamepadDisconnectedObserver;
  15135. private _updateCacheWhenTrackingDisabledObserver;
  15136. /**
  15137. * Initializes the controllers and their meshes
  15138. */
  15139. initControllers(): void;
  15140. }
  15141. }
  15142. declare module BABYLON {
  15143. /**
  15144. * Size options for a post process
  15145. */
  15146. export type PostProcessOptions = {
  15147. width: number;
  15148. height: number;
  15149. };
  15150. /**
  15151. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15152. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15153. */
  15154. export class PostProcess {
  15155. /** Name of the PostProcess. */
  15156. name: string;
  15157. /**
  15158. * Gets or sets the unique id of the post process
  15159. */
  15160. uniqueId: number;
  15161. /**
  15162. * Width of the texture to apply the post process on
  15163. */
  15164. width: number;
  15165. /**
  15166. * Height of the texture to apply the post process on
  15167. */
  15168. height: number;
  15169. /**
  15170. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15171. * @hidden
  15172. */
  15173. _outputTexture: Nullable<InternalTexture>;
  15174. /**
  15175. * Sampling mode used by the shader
  15176. * See https://doc.babylonjs.com/classes/3.1/texture
  15177. */
  15178. renderTargetSamplingMode: number;
  15179. /**
  15180. * Clear color to use when screen clearing
  15181. */
  15182. clearColor: Color4;
  15183. /**
  15184. * If the buffer needs to be cleared before applying the post process. (default: true)
  15185. * Should be set to false if shader will overwrite all previous pixels.
  15186. */
  15187. autoClear: boolean;
  15188. /**
  15189. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15190. */
  15191. alphaMode: number;
  15192. /**
  15193. * Sets the setAlphaBlendConstants of the babylon engine
  15194. */
  15195. alphaConstants: Color4;
  15196. /**
  15197. * Animations to be used for the post processing
  15198. */
  15199. animations: Animation[];
  15200. /**
  15201. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15202. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15203. */
  15204. enablePixelPerfectMode: boolean;
  15205. /**
  15206. * Force the postprocess to be applied without taking in account viewport
  15207. */
  15208. forceFullscreenViewport: boolean;
  15209. /**
  15210. * List of inspectable custom properties (used by the Inspector)
  15211. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15212. */
  15213. inspectableCustomProperties: IInspectable[];
  15214. /**
  15215. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15216. *
  15217. * | Value | Type | Description |
  15218. * | ----- | ----------------------------------- | ----------- |
  15219. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15220. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15221. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15222. *
  15223. */
  15224. scaleMode: number;
  15225. /**
  15226. * Force textures to be a power of two (default: false)
  15227. */
  15228. alwaysForcePOT: boolean;
  15229. private _samples;
  15230. /**
  15231. * Number of sample textures (default: 1)
  15232. */
  15233. samples: number;
  15234. /**
  15235. * Modify the scale of the post process to be the same as the viewport (default: false)
  15236. */
  15237. adaptScaleToCurrentViewport: boolean;
  15238. private _camera;
  15239. private _scene;
  15240. private _engine;
  15241. private _options;
  15242. private _reusable;
  15243. private _textureType;
  15244. /**
  15245. * Smart array of input and output textures for the post process.
  15246. * @hidden
  15247. */
  15248. _textures: SmartArray<InternalTexture>;
  15249. /**
  15250. * The index in _textures that corresponds to the output texture.
  15251. * @hidden
  15252. */
  15253. _currentRenderTextureInd: number;
  15254. private _effect;
  15255. private _samplers;
  15256. private _fragmentUrl;
  15257. private _vertexUrl;
  15258. private _parameters;
  15259. private _scaleRatio;
  15260. protected _indexParameters: any;
  15261. private _shareOutputWithPostProcess;
  15262. private _texelSize;
  15263. private _forcedOutputTexture;
  15264. /**
  15265. * Returns the fragment url or shader name used in the post process.
  15266. * @returns the fragment url or name in the shader store.
  15267. */
  15268. getEffectName(): string;
  15269. /**
  15270. * An event triggered when the postprocess is activated.
  15271. */
  15272. onActivateObservable: Observable<Camera>;
  15273. private _onActivateObserver;
  15274. /**
  15275. * A function that is added to the onActivateObservable
  15276. */
  15277. onActivate: Nullable<(camera: Camera) => void>;
  15278. /**
  15279. * An event triggered when the postprocess changes its size.
  15280. */
  15281. onSizeChangedObservable: Observable<PostProcess>;
  15282. private _onSizeChangedObserver;
  15283. /**
  15284. * A function that is added to the onSizeChangedObservable
  15285. */
  15286. onSizeChanged: (postProcess: PostProcess) => void;
  15287. /**
  15288. * An event triggered when the postprocess applies its effect.
  15289. */
  15290. onApplyObservable: Observable<Effect>;
  15291. private _onApplyObserver;
  15292. /**
  15293. * A function that is added to the onApplyObservable
  15294. */
  15295. onApply: (effect: Effect) => void;
  15296. /**
  15297. * An event triggered before rendering the postprocess
  15298. */
  15299. onBeforeRenderObservable: Observable<Effect>;
  15300. private _onBeforeRenderObserver;
  15301. /**
  15302. * A function that is added to the onBeforeRenderObservable
  15303. */
  15304. onBeforeRender: (effect: Effect) => void;
  15305. /**
  15306. * An event triggered after rendering the postprocess
  15307. */
  15308. onAfterRenderObservable: Observable<Effect>;
  15309. private _onAfterRenderObserver;
  15310. /**
  15311. * A function that is added to the onAfterRenderObservable
  15312. */
  15313. onAfterRender: (efect: Effect) => void;
  15314. /**
  15315. * 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
  15316. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15317. */
  15318. inputTexture: InternalTexture;
  15319. /**
  15320. * Gets the camera which post process is applied to.
  15321. * @returns The camera the post process is applied to.
  15322. */
  15323. getCamera(): Camera;
  15324. /**
  15325. * Gets the texel size of the postprocess.
  15326. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15327. */
  15328. readonly texelSize: Vector2;
  15329. /**
  15330. * Creates a new instance PostProcess
  15331. * @param name The name of the PostProcess.
  15332. * @param fragmentUrl The url of the fragment shader to be used.
  15333. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15334. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15335. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15336. * @param camera The camera to apply the render pass to.
  15337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15338. * @param engine The engine which the post process will be applied. (default: current engine)
  15339. * @param reusable If the post process can be reused on the same frame. (default: false)
  15340. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15341. * @param textureType Type of textures used when performing the post process. (default: 0)
  15342. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15343. * @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
  15344. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15345. */
  15346. constructor(
  15347. /** Name of the PostProcess. */
  15348. 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);
  15349. /**
  15350. * Gets a string idenfifying the name of the class
  15351. * @returns "PostProcess" string
  15352. */
  15353. getClassName(): string;
  15354. /**
  15355. * Gets the engine which this post process belongs to.
  15356. * @returns The engine the post process was enabled with.
  15357. */
  15358. getEngine(): Engine;
  15359. /**
  15360. * The effect that is created when initializing the post process.
  15361. * @returns The created effect corresponding the the postprocess.
  15362. */
  15363. getEffect(): Effect;
  15364. /**
  15365. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15366. * @param postProcess The post process to share the output with.
  15367. * @returns This post process.
  15368. */
  15369. shareOutputWith(postProcess: PostProcess): PostProcess;
  15370. /**
  15371. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15372. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15373. */
  15374. useOwnOutput(): void;
  15375. /**
  15376. * Updates the effect with the current post process compile time values and recompiles the shader.
  15377. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15378. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15379. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15380. * @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
  15381. * @param onCompiled Called when the shader has been compiled.
  15382. * @param onError Called if there is an error when compiling a shader.
  15383. */
  15384. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15385. /**
  15386. * The post process is reusable if it can be used multiple times within one frame.
  15387. * @returns If the post process is reusable
  15388. */
  15389. isReusable(): boolean;
  15390. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15391. markTextureDirty(): void;
  15392. /**
  15393. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15394. * 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.
  15395. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15396. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15397. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15398. * @returns The target texture that was bound to be written to.
  15399. */
  15400. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15401. /**
  15402. * If the post process is supported.
  15403. */
  15404. readonly isSupported: boolean;
  15405. /**
  15406. * The aspect ratio of the output texture.
  15407. */
  15408. readonly aspectRatio: number;
  15409. /**
  15410. * Get a value indicating if the post-process is ready to be used
  15411. * @returns true if the post-process is ready (shader is compiled)
  15412. */
  15413. isReady(): boolean;
  15414. /**
  15415. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15416. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15417. */
  15418. apply(): Nullable<Effect>;
  15419. private _disposeTextures;
  15420. /**
  15421. * Disposes the post process.
  15422. * @param camera The camera to dispose the post process on.
  15423. */
  15424. dispose(camera?: Camera): void;
  15425. }
  15426. }
  15427. declare module BABYLON {
  15428. /** @hidden */
  15429. export var kernelBlurVaryingDeclaration: {
  15430. name: string;
  15431. shader: string;
  15432. };
  15433. }
  15434. declare module BABYLON {
  15435. /** @hidden */
  15436. export var kernelBlurFragment: {
  15437. name: string;
  15438. shader: string;
  15439. };
  15440. }
  15441. declare module BABYLON {
  15442. /** @hidden */
  15443. export var kernelBlurFragment2: {
  15444. name: string;
  15445. shader: string;
  15446. };
  15447. }
  15448. declare module BABYLON {
  15449. /** @hidden */
  15450. export var kernelBlurPixelShader: {
  15451. name: string;
  15452. shader: string;
  15453. };
  15454. }
  15455. declare module BABYLON {
  15456. /** @hidden */
  15457. export var kernelBlurVertex: {
  15458. name: string;
  15459. shader: string;
  15460. };
  15461. }
  15462. declare module BABYLON {
  15463. /** @hidden */
  15464. export var kernelBlurVertexShader: {
  15465. name: string;
  15466. shader: string;
  15467. };
  15468. }
  15469. declare module BABYLON {
  15470. /**
  15471. * The Blur Post Process which blurs an image based on a kernel and direction.
  15472. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15473. */
  15474. export class BlurPostProcess extends PostProcess {
  15475. /** The direction in which to blur the image. */
  15476. direction: Vector2;
  15477. private blockCompilation;
  15478. protected _kernel: number;
  15479. protected _idealKernel: number;
  15480. protected _packedFloat: boolean;
  15481. private _staticDefines;
  15482. /**
  15483. * Sets the length in pixels of the blur sample region
  15484. */
  15485. /**
  15486. * Gets the length in pixels of the blur sample region
  15487. */
  15488. kernel: number;
  15489. /**
  15490. * Sets wether or not the blur needs to unpack/repack floats
  15491. */
  15492. /**
  15493. * Gets wether or not the blur is unpacking/repacking floats
  15494. */
  15495. packedFloat: boolean;
  15496. /**
  15497. * Creates a new instance BlurPostProcess
  15498. * @param name The name of the effect.
  15499. * @param direction The direction in which to blur the image.
  15500. * @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.
  15501. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15502. * @param camera The camera to apply the render pass to.
  15503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15504. * @param engine The engine which the post process will be applied. (default: current engine)
  15505. * @param reusable If the post process can be reused on the same frame. (default: false)
  15506. * @param textureType Type of textures used when performing the post process. (default: 0)
  15507. * @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)
  15508. */
  15509. constructor(name: string,
  15510. /** The direction in which to blur the image. */
  15511. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15512. /**
  15513. * Updates the effect with the current post process compile time values and recompiles the shader.
  15514. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15515. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15516. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15517. * @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
  15518. * @param onCompiled Called when the shader has been compiled.
  15519. * @param onError Called if there is an error when compiling a shader.
  15520. */
  15521. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15522. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15523. /**
  15524. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15525. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15526. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15527. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15528. * The gaps between physical kernels are compensated for in the weighting of the samples
  15529. * @param idealKernel Ideal blur kernel.
  15530. * @return Nearest best kernel.
  15531. */
  15532. protected _nearestBestKernel(idealKernel: number): number;
  15533. /**
  15534. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15535. * @param x The point on the Gaussian distribution to sample.
  15536. * @return the value of the Gaussian function at x.
  15537. */
  15538. protected _gaussianWeight(x: number): number;
  15539. /**
  15540. * Generates a string that can be used as a floating point number in GLSL.
  15541. * @param x Value to print.
  15542. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15543. * @return GLSL float string.
  15544. */
  15545. protected _glslFloat(x: number, decimalFigures?: number): string;
  15546. }
  15547. }
  15548. declare module BABYLON {
  15549. /**
  15550. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15551. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15552. * You can then easily use it as a reflectionTexture on a flat surface.
  15553. * In case the surface is not a plane, please consider relying on reflection probes.
  15554. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15555. */
  15556. export class MirrorTexture extends RenderTargetTexture {
  15557. private scene;
  15558. /**
  15559. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15560. * 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.
  15561. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15562. */
  15563. mirrorPlane: Plane;
  15564. /**
  15565. * Define the blur ratio used to blur the reflection if needed.
  15566. */
  15567. blurRatio: number;
  15568. /**
  15569. * Define the adaptive blur kernel used to blur the reflection if needed.
  15570. * This will autocompute the closest best match for the `blurKernel`
  15571. */
  15572. adaptiveBlurKernel: number;
  15573. /**
  15574. * Define the blur kernel used to blur the reflection if needed.
  15575. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15576. */
  15577. blurKernel: number;
  15578. /**
  15579. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15580. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15581. */
  15582. blurKernelX: number;
  15583. /**
  15584. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15585. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15586. */
  15587. blurKernelY: number;
  15588. private _autoComputeBlurKernel;
  15589. protected _onRatioRescale(): void;
  15590. private _updateGammaSpace;
  15591. private _imageProcessingConfigChangeObserver;
  15592. private _transformMatrix;
  15593. private _mirrorMatrix;
  15594. private _savedViewMatrix;
  15595. private _blurX;
  15596. private _blurY;
  15597. private _adaptiveBlurKernel;
  15598. private _blurKernelX;
  15599. private _blurKernelY;
  15600. private _blurRatio;
  15601. /**
  15602. * Instantiates a Mirror Texture.
  15603. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15604. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15605. * You can then easily use it as a reflectionTexture on a flat surface.
  15606. * In case the surface is not a plane, please consider relying on reflection probes.
  15607. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15608. * @param name
  15609. * @param size
  15610. * @param scene
  15611. * @param generateMipMaps
  15612. * @param type
  15613. * @param samplingMode
  15614. * @param generateDepthBuffer
  15615. */
  15616. constructor(name: string, size: number | {
  15617. width: number;
  15618. height: number;
  15619. } | {
  15620. ratio: number;
  15621. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15622. private _preparePostProcesses;
  15623. /**
  15624. * Clone the mirror texture.
  15625. * @returns the cloned texture
  15626. */
  15627. clone(): MirrorTexture;
  15628. /**
  15629. * Serialize the texture to a JSON representation you could use in Parse later on
  15630. * @returns the serialized JSON representation
  15631. */
  15632. serialize(): any;
  15633. /**
  15634. * Dispose the texture and release its associated resources.
  15635. */
  15636. dispose(): void;
  15637. }
  15638. }
  15639. declare module BABYLON {
  15640. /**
  15641. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15642. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15643. */
  15644. export class Texture extends BaseTexture {
  15645. /**
  15646. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15647. */
  15648. static SerializeBuffers: boolean;
  15649. /** @hidden */
  15650. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15651. /** @hidden */
  15652. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15653. /** @hidden */
  15654. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15655. /** nearest is mag = nearest and min = nearest and mip = linear */
  15656. static readonly NEAREST_SAMPLINGMODE: number;
  15657. /** nearest is mag = nearest and min = nearest and mip = linear */
  15658. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15659. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15660. static readonly BILINEAR_SAMPLINGMODE: number;
  15661. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15662. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15663. /** Trilinear is mag = linear and min = linear and mip = linear */
  15664. static readonly TRILINEAR_SAMPLINGMODE: number;
  15665. /** Trilinear is mag = linear and min = linear and mip = linear */
  15666. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15667. /** mag = nearest and min = nearest and mip = nearest */
  15668. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15669. /** mag = nearest and min = linear and mip = nearest */
  15670. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15671. /** mag = nearest and min = linear and mip = linear */
  15672. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15673. /** mag = nearest and min = linear and mip = none */
  15674. static readonly NEAREST_LINEAR: number;
  15675. /** mag = nearest and min = nearest and mip = none */
  15676. static readonly NEAREST_NEAREST: number;
  15677. /** mag = linear and min = nearest and mip = nearest */
  15678. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15679. /** mag = linear and min = nearest and mip = linear */
  15680. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15681. /** mag = linear and min = linear and mip = none */
  15682. static readonly LINEAR_LINEAR: number;
  15683. /** mag = linear and min = nearest and mip = none */
  15684. static readonly LINEAR_NEAREST: number;
  15685. /** Explicit coordinates mode */
  15686. static readonly EXPLICIT_MODE: number;
  15687. /** Spherical coordinates mode */
  15688. static readonly SPHERICAL_MODE: number;
  15689. /** Planar coordinates mode */
  15690. static readonly PLANAR_MODE: number;
  15691. /** Cubic coordinates mode */
  15692. static readonly CUBIC_MODE: number;
  15693. /** Projection coordinates mode */
  15694. static readonly PROJECTION_MODE: number;
  15695. /** Inverse Cubic coordinates mode */
  15696. static readonly SKYBOX_MODE: number;
  15697. /** Inverse Cubic coordinates mode */
  15698. static readonly INVCUBIC_MODE: number;
  15699. /** Equirectangular coordinates mode */
  15700. static readonly EQUIRECTANGULAR_MODE: number;
  15701. /** Equirectangular Fixed coordinates mode */
  15702. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15703. /** Equirectangular Fixed Mirrored coordinates mode */
  15704. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15705. /** Texture is not repeating outside of 0..1 UVs */
  15706. static readonly CLAMP_ADDRESSMODE: number;
  15707. /** Texture is repeating outside of 0..1 UVs */
  15708. static readonly WRAP_ADDRESSMODE: number;
  15709. /** Texture is repeating and mirrored */
  15710. static readonly MIRROR_ADDRESSMODE: number;
  15711. /**
  15712. * 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
  15713. */
  15714. static UseSerializedUrlIfAny: boolean;
  15715. /**
  15716. * Define the url of the texture.
  15717. */
  15718. url: Nullable<string>;
  15719. /**
  15720. * Define an offset on the texture to offset the u coordinates of the UVs
  15721. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15722. */
  15723. uOffset: number;
  15724. /**
  15725. * Define an offset on the texture to offset the v coordinates of the UVs
  15726. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15727. */
  15728. vOffset: number;
  15729. /**
  15730. * Define an offset on the texture to scale the u coordinates of the UVs
  15731. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15732. */
  15733. uScale: number;
  15734. /**
  15735. * Define an offset on the texture to scale the v coordinates of the UVs
  15736. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15737. */
  15738. vScale: number;
  15739. /**
  15740. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15741. * @see http://doc.babylonjs.com/how_to/more_materials
  15742. */
  15743. uAng: number;
  15744. /**
  15745. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15746. * @see http://doc.babylonjs.com/how_to/more_materials
  15747. */
  15748. vAng: number;
  15749. /**
  15750. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15751. * @see http://doc.babylonjs.com/how_to/more_materials
  15752. */
  15753. wAng: number;
  15754. /**
  15755. * Defines the center of rotation (U)
  15756. */
  15757. uRotationCenter: number;
  15758. /**
  15759. * Defines the center of rotation (V)
  15760. */
  15761. vRotationCenter: number;
  15762. /**
  15763. * Defines the center of rotation (W)
  15764. */
  15765. wRotationCenter: number;
  15766. /**
  15767. * Are mip maps generated for this texture or not.
  15768. */
  15769. readonly noMipmap: boolean;
  15770. /**
  15771. * List of inspectable custom properties (used by the Inspector)
  15772. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15773. */
  15774. inspectableCustomProperties: Nullable<IInspectable[]>;
  15775. private _noMipmap;
  15776. /** @hidden */
  15777. _invertY: boolean;
  15778. private _rowGenerationMatrix;
  15779. private _cachedTextureMatrix;
  15780. private _projectionModeMatrix;
  15781. private _t0;
  15782. private _t1;
  15783. private _t2;
  15784. private _cachedUOffset;
  15785. private _cachedVOffset;
  15786. private _cachedUScale;
  15787. private _cachedVScale;
  15788. private _cachedUAng;
  15789. private _cachedVAng;
  15790. private _cachedWAng;
  15791. private _cachedProjectionMatrixId;
  15792. private _cachedCoordinatesMode;
  15793. /** @hidden */
  15794. protected _initialSamplingMode: number;
  15795. /** @hidden */
  15796. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15797. private _deleteBuffer;
  15798. protected _format: Nullable<number>;
  15799. private _delayedOnLoad;
  15800. private _delayedOnError;
  15801. /**
  15802. * Observable triggered once the texture has been loaded.
  15803. */
  15804. onLoadObservable: Observable<Texture>;
  15805. protected _isBlocking: boolean;
  15806. /**
  15807. * Is the texture preventing material to render while loading.
  15808. * If false, a default texture will be used instead of the loading one during the preparation step.
  15809. */
  15810. isBlocking: boolean;
  15811. /**
  15812. * Get the current sampling mode associated with the texture.
  15813. */
  15814. readonly samplingMode: number;
  15815. /**
  15816. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15817. */
  15818. readonly invertY: boolean;
  15819. /**
  15820. * Instantiates a new texture.
  15821. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15822. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15823. * @param url define the url of the picture to load as a texture
  15824. * @param scene define the scene or engine the texture will belong to
  15825. * @param noMipmap define if the texture will require mip maps or not
  15826. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15827. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15828. * @param onLoad define a callback triggered when the texture has been loaded
  15829. * @param onError define a callback triggered when an error occurred during the loading session
  15830. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15831. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15832. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15833. */
  15834. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15835. /**
  15836. * Update the url (and optional buffer) of this texture if url was null during construction.
  15837. * @param url the url of the texture
  15838. * @param buffer the buffer of the texture (defaults to null)
  15839. * @param onLoad callback called when the texture is loaded (defaults to null)
  15840. */
  15841. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15842. /**
  15843. * Finish the loading sequence of a texture flagged as delayed load.
  15844. * @hidden
  15845. */
  15846. delayLoad(): void;
  15847. private _prepareRowForTextureGeneration;
  15848. /**
  15849. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15850. * @returns the transform matrix of the texture.
  15851. */
  15852. getTextureMatrix(): Matrix;
  15853. /**
  15854. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15855. * @returns The reflection texture transform
  15856. */
  15857. getReflectionTextureMatrix(): Matrix;
  15858. /**
  15859. * Clones the texture.
  15860. * @returns the cloned texture
  15861. */
  15862. clone(): Texture;
  15863. /**
  15864. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15865. * @returns The JSON representation of the texture
  15866. */
  15867. serialize(): any;
  15868. /**
  15869. * Get the current class name of the texture useful for serialization or dynamic coding.
  15870. * @returns "Texture"
  15871. */
  15872. getClassName(): string;
  15873. /**
  15874. * Dispose the texture and release its associated resources.
  15875. */
  15876. dispose(): void;
  15877. /**
  15878. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15879. * @param parsedTexture Define the JSON representation of the texture
  15880. * @param scene Define the scene the parsed texture should be instantiated in
  15881. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15882. * @returns The parsed texture if successful
  15883. */
  15884. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15885. /**
  15886. * Creates a texture from its base 64 representation.
  15887. * @param data Define the base64 payload without the data: prefix
  15888. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15889. * @param scene Define the scene the texture should belong to
  15890. * @param noMipmap Forces the texture to not create mip map information if true
  15891. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15892. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15893. * @param onLoad define a callback triggered when the texture has been loaded
  15894. * @param onError define a callback triggered when an error occurred during the loading session
  15895. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15896. * @returns the created texture
  15897. */
  15898. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15899. /**
  15900. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15901. * @param data Define the base64 payload without the data: prefix
  15902. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15903. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15904. * @param scene Define the scene the texture should belong to
  15905. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15906. * @param noMipmap Forces the texture to not create mip map information if true
  15907. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15908. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15909. * @param onLoad define a callback triggered when the texture has been loaded
  15910. * @param onError define a callback triggered when an error occurred during the loading session
  15911. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15912. * @returns the created texture
  15913. */
  15914. 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;
  15915. }
  15916. }
  15917. declare module BABYLON {
  15918. /**
  15919. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15920. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15921. */
  15922. export class PostProcessManager {
  15923. private _scene;
  15924. private _indexBuffer;
  15925. private _vertexBuffers;
  15926. /**
  15927. * Creates a new instance PostProcess
  15928. * @param scene The scene that the post process is associated with.
  15929. */
  15930. constructor(scene: Scene);
  15931. private _prepareBuffers;
  15932. private _buildIndexBuffer;
  15933. /**
  15934. * Rebuilds the vertex buffers of the manager.
  15935. * @hidden
  15936. */
  15937. _rebuild(): void;
  15938. /**
  15939. * Prepares a frame to be run through a post process.
  15940. * @param sourceTexture The input texture to the post procesess. (default: null)
  15941. * @param postProcesses An array of post processes to be run. (default: null)
  15942. * @returns True if the post processes were able to be run.
  15943. * @hidden
  15944. */
  15945. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15946. /**
  15947. * Manually render a set of post processes to a texture.
  15948. * @param postProcesses An array of post processes to be run.
  15949. * @param targetTexture The target texture to render to.
  15950. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15951. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15952. * @param lodLevel defines which lod of the texture to render to
  15953. */
  15954. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15955. /**
  15956. * Finalize the result of the output of the postprocesses.
  15957. * @param doNotPresent If true the result will not be displayed to the screen.
  15958. * @param targetTexture The target texture to render to.
  15959. * @param faceIndex The index of the face to bind the target texture to.
  15960. * @param postProcesses The array of post processes to render.
  15961. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15962. * @hidden
  15963. */
  15964. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15965. /**
  15966. * Disposes of the post process manager.
  15967. */
  15968. dispose(): void;
  15969. }
  15970. }
  15971. declare module BABYLON {
  15972. /** Interface used by value gradients (color, factor, ...) */
  15973. export interface IValueGradient {
  15974. /**
  15975. * Gets or sets the gradient value (between 0 and 1)
  15976. */
  15977. gradient: number;
  15978. }
  15979. /** Class used to store color4 gradient */
  15980. export class ColorGradient implements IValueGradient {
  15981. /**
  15982. * Gets or sets the gradient value (between 0 and 1)
  15983. */
  15984. gradient: number;
  15985. /**
  15986. * Gets or sets first associated color
  15987. */
  15988. color1: Color4;
  15989. /**
  15990. * Gets or sets second associated color
  15991. */
  15992. color2?: Color4;
  15993. /**
  15994. * Will get a color picked randomly between color1 and color2.
  15995. * If color2 is undefined then color1 will be used
  15996. * @param result defines the target Color4 to store the result in
  15997. */
  15998. getColorToRef(result: Color4): void;
  15999. }
  16000. /** Class used to store color 3 gradient */
  16001. export class Color3Gradient implements IValueGradient {
  16002. /**
  16003. * Gets or sets the gradient value (between 0 and 1)
  16004. */
  16005. gradient: number;
  16006. /**
  16007. * Gets or sets the associated color
  16008. */
  16009. color: Color3;
  16010. }
  16011. /** Class used to store factor gradient */
  16012. export class FactorGradient implements IValueGradient {
  16013. /**
  16014. * Gets or sets the gradient value (between 0 and 1)
  16015. */
  16016. gradient: number;
  16017. /**
  16018. * Gets or sets first associated factor
  16019. */
  16020. factor1: number;
  16021. /**
  16022. * Gets or sets second associated factor
  16023. */
  16024. factor2?: number;
  16025. /**
  16026. * Will get a number picked randomly between factor1 and factor2.
  16027. * If factor2 is undefined then factor1 will be used
  16028. * @returns the picked number
  16029. */
  16030. getFactor(): number;
  16031. }
  16032. /**
  16033. * Helper used to simplify some generic gradient tasks
  16034. */
  16035. export class GradientHelper {
  16036. /**
  16037. * Gets the current gradient from an array of IValueGradient
  16038. * @param ratio defines the current ratio to get
  16039. * @param gradients defines the array of IValueGradient
  16040. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16041. */
  16042. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16043. }
  16044. }
  16045. declare module BABYLON {
  16046. interface ThinEngine {
  16047. /**
  16048. * Creates a dynamic texture
  16049. * @param width defines the width of the texture
  16050. * @param height defines the height of the texture
  16051. * @param generateMipMaps defines if the engine should generate the mip levels
  16052. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16053. * @returns the dynamic texture inside an InternalTexture
  16054. */
  16055. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16056. /**
  16057. * Update the content of a dynamic texture
  16058. * @param texture defines the texture to update
  16059. * @param canvas defines the canvas containing the source
  16060. * @param invertY defines if data must be stored with Y axis inverted
  16061. * @param premulAlpha defines if alpha is stored as premultiplied
  16062. * @param format defines the format of the data
  16063. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16064. */
  16065. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16066. }
  16067. }
  16068. declare module BABYLON {
  16069. /**
  16070. * A class extending Texture allowing drawing on a texture
  16071. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16072. */
  16073. export class DynamicTexture extends Texture {
  16074. private _generateMipMaps;
  16075. private _canvas;
  16076. private _context;
  16077. private _engine;
  16078. /**
  16079. * Creates a DynamicTexture
  16080. * @param name defines the name of the texture
  16081. * @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
  16082. * @param scene defines the scene where you want the texture
  16083. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16084. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16085. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16086. */
  16087. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16088. /**
  16089. * Get the current class name of the texture useful for serialization or dynamic coding.
  16090. * @returns "DynamicTexture"
  16091. */
  16092. getClassName(): string;
  16093. /**
  16094. * Gets the current state of canRescale
  16095. */
  16096. readonly canRescale: boolean;
  16097. private _recreate;
  16098. /**
  16099. * Scales the texture
  16100. * @param ratio the scale factor to apply to both width and height
  16101. */
  16102. scale(ratio: number): void;
  16103. /**
  16104. * Resizes the texture
  16105. * @param width the new width
  16106. * @param height the new height
  16107. */
  16108. scaleTo(width: number, height: number): void;
  16109. /**
  16110. * Gets the context of the canvas used by the texture
  16111. * @returns the canvas context of the dynamic texture
  16112. */
  16113. getContext(): CanvasRenderingContext2D;
  16114. /**
  16115. * Clears the texture
  16116. */
  16117. clear(): void;
  16118. /**
  16119. * Updates the texture
  16120. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16121. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16122. */
  16123. update(invertY?: boolean, premulAlpha?: boolean): void;
  16124. /**
  16125. * Draws text onto the texture
  16126. * @param text defines the text to be drawn
  16127. * @param x defines the placement of the text from the left
  16128. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16129. * @param font defines the font to be used with font-style, font-size, font-name
  16130. * @param color defines the color used for the text
  16131. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16132. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16133. * @param update defines whether texture is immediately update (default is true)
  16134. */
  16135. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16136. /**
  16137. * Clones the texture
  16138. * @returns the clone of the texture.
  16139. */
  16140. clone(): DynamicTexture;
  16141. /**
  16142. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16143. * @returns a serialized dynamic texture object
  16144. */
  16145. serialize(): any;
  16146. /** @hidden */
  16147. _rebuild(): void;
  16148. }
  16149. }
  16150. declare module BABYLON {
  16151. interface AbstractScene {
  16152. /**
  16153. * The list of procedural textures added to the scene
  16154. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16155. */
  16156. proceduralTextures: Array<ProceduralTexture>;
  16157. }
  16158. /**
  16159. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16160. * in a given scene.
  16161. */
  16162. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16163. /**
  16164. * The component name helpfull to identify the component in the list of scene components.
  16165. */
  16166. readonly name: string;
  16167. /**
  16168. * The scene the component belongs to.
  16169. */
  16170. scene: Scene;
  16171. /**
  16172. * Creates a new instance of the component for the given scene
  16173. * @param scene Defines the scene to register the component in
  16174. */
  16175. constructor(scene: Scene);
  16176. /**
  16177. * Registers the component in a given scene
  16178. */
  16179. register(): void;
  16180. /**
  16181. * Rebuilds the elements related to this component in case of
  16182. * context lost for instance.
  16183. */
  16184. rebuild(): void;
  16185. /**
  16186. * Disposes the component and the associated ressources.
  16187. */
  16188. dispose(): void;
  16189. private _beforeClear;
  16190. }
  16191. }
  16192. declare module BABYLON {
  16193. interface ThinEngine {
  16194. /**
  16195. * Creates a new render target cube texture
  16196. * @param size defines the size of the texture
  16197. * @param options defines the options used to create the texture
  16198. * @returns a new render target cube texture stored in an InternalTexture
  16199. */
  16200. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16201. }
  16202. }
  16203. declare module BABYLON {
  16204. /** @hidden */
  16205. export var proceduralVertexShader: {
  16206. name: string;
  16207. shader: string;
  16208. };
  16209. }
  16210. declare module BABYLON {
  16211. /**
  16212. * 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.
  16213. * This is the base class of any Procedural texture and contains most of the shareable code.
  16214. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16215. */
  16216. export class ProceduralTexture extends Texture {
  16217. isCube: boolean;
  16218. /**
  16219. * Define if the texture is enabled or not (disabled texture will not render)
  16220. */
  16221. isEnabled: boolean;
  16222. /**
  16223. * Define if the texture must be cleared before rendering (default is true)
  16224. */
  16225. autoClear: boolean;
  16226. /**
  16227. * Callback called when the texture is generated
  16228. */
  16229. onGenerated: () => void;
  16230. /**
  16231. * Event raised when the texture is generated
  16232. */
  16233. onGeneratedObservable: Observable<ProceduralTexture>;
  16234. /** @hidden */
  16235. _generateMipMaps: boolean;
  16236. /** @hidden **/
  16237. _effect: Effect;
  16238. /** @hidden */
  16239. _textures: {
  16240. [key: string]: Texture;
  16241. };
  16242. private _size;
  16243. private _currentRefreshId;
  16244. private _refreshRate;
  16245. private _vertexBuffers;
  16246. private _indexBuffer;
  16247. private _uniforms;
  16248. private _samplers;
  16249. private _fragment;
  16250. private _floats;
  16251. private _ints;
  16252. private _floatsArrays;
  16253. private _colors3;
  16254. private _colors4;
  16255. private _vectors2;
  16256. private _vectors3;
  16257. private _matrices;
  16258. private _fallbackTexture;
  16259. private _fallbackTextureUsed;
  16260. private _engine;
  16261. private _cachedDefines;
  16262. private _contentUpdateId;
  16263. private _contentData;
  16264. /**
  16265. * Instantiates a new procedural texture.
  16266. * 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.
  16267. * This is the base class of any Procedural texture and contains most of the shareable code.
  16268. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16269. * @param name Define the name of the texture
  16270. * @param size Define the size of the texture to create
  16271. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16272. * @param scene Define the scene the texture belongs to
  16273. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16274. * @param generateMipMaps Define if the texture should creates mip maps or not
  16275. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16276. */
  16277. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16278. /**
  16279. * The effect that is created when initializing the post process.
  16280. * @returns The created effect corresponding the the postprocess.
  16281. */
  16282. getEffect(): Effect;
  16283. /**
  16284. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16285. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16286. */
  16287. getContent(): Nullable<ArrayBufferView>;
  16288. private _createIndexBuffer;
  16289. /** @hidden */
  16290. _rebuild(): void;
  16291. /**
  16292. * Resets the texture in order to recreate its associated resources.
  16293. * This can be called in case of context loss
  16294. */
  16295. reset(): void;
  16296. protected _getDefines(): string;
  16297. /**
  16298. * Is the texture ready to be used ? (rendered at least once)
  16299. * @returns true if ready, otherwise, false.
  16300. */
  16301. isReady(): boolean;
  16302. /**
  16303. * Resets the refresh counter of the texture and start bak from scratch.
  16304. * Could be useful to regenerate the texture if it is setup to render only once.
  16305. */
  16306. resetRefreshCounter(): void;
  16307. /**
  16308. * Set the fragment shader to use in order to render the texture.
  16309. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16310. */
  16311. setFragment(fragment: any): void;
  16312. /**
  16313. * Define the refresh rate of the texture or the rendering frequency.
  16314. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16315. */
  16316. refreshRate: number;
  16317. /** @hidden */
  16318. _shouldRender(): boolean;
  16319. /**
  16320. * Get the size the texture is rendering at.
  16321. * @returns the size (texture is always squared)
  16322. */
  16323. getRenderSize(): number;
  16324. /**
  16325. * Resize the texture to new value.
  16326. * @param size Define the new size the texture should have
  16327. * @param generateMipMaps Define whether the new texture should create mip maps
  16328. */
  16329. resize(size: number, generateMipMaps: boolean): void;
  16330. private _checkUniform;
  16331. /**
  16332. * Set a texture in the shader program used to render.
  16333. * @param name Define the name of the uniform samplers as defined in the shader
  16334. * @param texture Define the texture to bind to this sampler
  16335. * @return the texture itself allowing "fluent" like uniform updates
  16336. */
  16337. setTexture(name: string, texture: Texture): ProceduralTexture;
  16338. /**
  16339. * Set a float in the shader.
  16340. * @param name Define the name of the uniform as defined in the shader
  16341. * @param value Define the value to give to the uniform
  16342. * @return the texture itself allowing "fluent" like uniform updates
  16343. */
  16344. setFloat(name: string, value: number): ProceduralTexture;
  16345. /**
  16346. * Set a int in the shader.
  16347. * @param name Define the name of the uniform as defined in the shader
  16348. * @param value Define the value to give to the uniform
  16349. * @return the texture itself allowing "fluent" like uniform updates
  16350. */
  16351. setInt(name: string, value: number): ProceduralTexture;
  16352. /**
  16353. * Set an array of floats in the shader.
  16354. * @param name Define the name of the uniform as defined in the shader
  16355. * @param value Define the value to give to the uniform
  16356. * @return the texture itself allowing "fluent" like uniform updates
  16357. */
  16358. setFloats(name: string, value: number[]): ProceduralTexture;
  16359. /**
  16360. * Set a vec3 in the shader from a Color3.
  16361. * @param name Define the name of the uniform as defined in the shader
  16362. * @param value Define the value to give to the uniform
  16363. * @return the texture itself allowing "fluent" like uniform updates
  16364. */
  16365. setColor3(name: string, value: Color3): ProceduralTexture;
  16366. /**
  16367. * Set a vec4 in the shader from a Color4.
  16368. * @param name Define the name of the uniform as defined in the shader
  16369. * @param value Define the value to give to the uniform
  16370. * @return the texture itself allowing "fluent" like uniform updates
  16371. */
  16372. setColor4(name: string, value: Color4): ProceduralTexture;
  16373. /**
  16374. * Set a vec2 in the shader from a Vector2.
  16375. * @param name Define the name of the uniform as defined in the shader
  16376. * @param value Define the value to give to the uniform
  16377. * @return the texture itself allowing "fluent" like uniform updates
  16378. */
  16379. setVector2(name: string, value: Vector2): ProceduralTexture;
  16380. /**
  16381. * Set a vec3 in the shader from a Vector3.
  16382. * @param name Define the name of the uniform as defined in the shader
  16383. * @param value Define the value to give to the uniform
  16384. * @return the texture itself allowing "fluent" like uniform updates
  16385. */
  16386. setVector3(name: string, value: Vector3): ProceduralTexture;
  16387. /**
  16388. * Set a mat4 in the shader from a MAtrix.
  16389. * @param name Define the name of the uniform as defined in the shader
  16390. * @param value Define the value to give to the uniform
  16391. * @return the texture itself allowing "fluent" like uniform updates
  16392. */
  16393. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16394. /**
  16395. * Render the texture to its associated render target.
  16396. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16397. */
  16398. render(useCameraPostProcess?: boolean): void;
  16399. /**
  16400. * Clone the texture.
  16401. * @returns the cloned texture
  16402. */
  16403. clone(): ProceduralTexture;
  16404. /**
  16405. * Dispose the texture and release its asoociated resources.
  16406. */
  16407. dispose(): void;
  16408. }
  16409. }
  16410. declare module BABYLON {
  16411. /**
  16412. * This represents the base class for particle system in Babylon.
  16413. * 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.
  16414. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16415. * @example https://doc.babylonjs.com/babylon101/particles
  16416. */
  16417. export class BaseParticleSystem {
  16418. /**
  16419. * Source color is added to the destination color without alpha affecting the result
  16420. */
  16421. static BLENDMODE_ONEONE: number;
  16422. /**
  16423. * Blend current color and particle color using particle’s alpha
  16424. */
  16425. static BLENDMODE_STANDARD: number;
  16426. /**
  16427. * Add current color and particle color multiplied by particle’s alpha
  16428. */
  16429. static BLENDMODE_ADD: number;
  16430. /**
  16431. * Multiply current color with particle color
  16432. */
  16433. static BLENDMODE_MULTIPLY: number;
  16434. /**
  16435. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16436. */
  16437. static BLENDMODE_MULTIPLYADD: number;
  16438. /**
  16439. * List of animations used by the particle system.
  16440. */
  16441. animations: Animation[];
  16442. /**
  16443. * The id of the Particle system.
  16444. */
  16445. id: string;
  16446. /**
  16447. * The friendly name of the Particle system.
  16448. */
  16449. name: string;
  16450. /**
  16451. * The rendering group used by the Particle system to chose when to render.
  16452. */
  16453. renderingGroupId: number;
  16454. /**
  16455. * The emitter represents the Mesh or position we are attaching the particle system to.
  16456. */
  16457. emitter: Nullable<AbstractMesh | Vector3>;
  16458. /**
  16459. * The maximum number of particles to emit per frame
  16460. */
  16461. emitRate: number;
  16462. /**
  16463. * If you want to launch only a few particles at once, that can be done, as well.
  16464. */
  16465. manualEmitCount: number;
  16466. /**
  16467. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16468. */
  16469. updateSpeed: number;
  16470. /**
  16471. * The amount of time the particle system is running (depends of the overall update speed).
  16472. */
  16473. targetStopDuration: number;
  16474. /**
  16475. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16476. */
  16477. disposeOnStop: boolean;
  16478. /**
  16479. * Minimum power of emitting particles.
  16480. */
  16481. minEmitPower: number;
  16482. /**
  16483. * Maximum power of emitting particles.
  16484. */
  16485. maxEmitPower: number;
  16486. /**
  16487. * Minimum life time of emitting particles.
  16488. */
  16489. minLifeTime: number;
  16490. /**
  16491. * Maximum life time of emitting particles.
  16492. */
  16493. maxLifeTime: number;
  16494. /**
  16495. * Minimum Size of emitting particles.
  16496. */
  16497. minSize: number;
  16498. /**
  16499. * Maximum Size of emitting particles.
  16500. */
  16501. maxSize: number;
  16502. /**
  16503. * Minimum scale of emitting particles on X axis.
  16504. */
  16505. minScaleX: number;
  16506. /**
  16507. * Maximum scale of emitting particles on X axis.
  16508. */
  16509. maxScaleX: number;
  16510. /**
  16511. * Minimum scale of emitting particles on Y axis.
  16512. */
  16513. minScaleY: number;
  16514. /**
  16515. * Maximum scale of emitting particles on Y axis.
  16516. */
  16517. maxScaleY: number;
  16518. /**
  16519. * Gets or sets the minimal initial rotation in radians.
  16520. */
  16521. minInitialRotation: number;
  16522. /**
  16523. * Gets or sets the maximal initial rotation in radians.
  16524. */
  16525. maxInitialRotation: number;
  16526. /**
  16527. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16528. */
  16529. minAngularSpeed: number;
  16530. /**
  16531. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16532. */
  16533. maxAngularSpeed: number;
  16534. /**
  16535. * The texture used to render each particle. (this can be a spritesheet)
  16536. */
  16537. particleTexture: Nullable<Texture>;
  16538. /**
  16539. * The layer mask we are rendering the particles through.
  16540. */
  16541. layerMask: number;
  16542. /**
  16543. * This can help using your own shader to render the particle system.
  16544. * The according effect will be created
  16545. */
  16546. customShader: any;
  16547. /**
  16548. * By default particle system starts as soon as they are created. This prevents the
  16549. * automatic start to happen and let you decide when to start emitting particles.
  16550. */
  16551. preventAutoStart: boolean;
  16552. private _noiseTexture;
  16553. /**
  16554. * Gets or sets a texture used to add random noise to particle positions
  16555. */
  16556. noiseTexture: Nullable<ProceduralTexture>;
  16557. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16558. noiseStrength: Vector3;
  16559. /**
  16560. * Callback triggered when the particle animation is ending.
  16561. */
  16562. onAnimationEnd: Nullable<() => void>;
  16563. /**
  16564. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16565. */
  16566. blendMode: number;
  16567. /**
  16568. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16569. * to override the particles.
  16570. */
  16571. forceDepthWrite: boolean;
  16572. /** 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 */
  16573. preWarmCycles: number;
  16574. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16575. preWarmStepOffset: number;
  16576. /**
  16577. * 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)
  16578. */
  16579. spriteCellChangeSpeed: number;
  16580. /**
  16581. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16582. */
  16583. startSpriteCellID: number;
  16584. /**
  16585. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16586. */
  16587. endSpriteCellID: number;
  16588. /**
  16589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16590. */
  16591. spriteCellWidth: number;
  16592. /**
  16593. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16594. */
  16595. spriteCellHeight: number;
  16596. /**
  16597. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16598. */
  16599. spriteRandomStartCell: boolean;
  16600. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16601. translationPivot: Vector2;
  16602. /** @hidden */
  16603. protected _isAnimationSheetEnabled: boolean;
  16604. /**
  16605. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16606. */
  16607. beginAnimationOnStart: boolean;
  16608. /**
  16609. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16610. */
  16611. beginAnimationFrom: number;
  16612. /**
  16613. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16614. */
  16615. beginAnimationTo: number;
  16616. /**
  16617. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16618. */
  16619. beginAnimationLoop: boolean;
  16620. /**
  16621. * Gets or sets a world offset applied to all particles
  16622. */
  16623. worldOffset: Vector3;
  16624. /**
  16625. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16626. */
  16627. isAnimationSheetEnabled: boolean;
  16628. /**
  16629. * Get hosting scene
  16630. * @returns the scene
  16631. */
  16632. getScene(): Scene;
  16633. /**
  16634. * You can use gravity if you want to give an orientation to your particles.
  16635. */
  16636. gravity: Vector3;
  16637. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16638. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16639. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16640. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16641. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16642. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16643. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16644. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16645. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16646. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16647. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16648. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16649. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16650. /**
  16651. * Defines the delay in milliseconds before starting the system (0 by default)
  16652. */
  16653. startDelay: number;
  16654. /**
  16655. * Gets the current list of drag gradients.
  16656. * You must use addDragGradient and removeDragGradient to udpate this list
  16657. * @returns the list of drag gradients
  16658. */
  16659. getDragGradients(): Nullable<Array<FactorGradient>>;
  16660. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16661. limitVelocityDamping: number;
  16662. /**
  16663. * Gets the current list of limit velocity gradients.
  16664. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16665. * @returns the list of limit velocity gradients
  16666. */
  16667. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16668. /**
  16669. * Gets the current list of color gradients.
  16670. * You must use addColorGradient and removeColorGradient to udpate this list
  16671. * @returns the list of color gradients
  16672. */
  16673. getColorGradients(): Nullable<Array<ColorGradient>>;
  16674. /**
  16675. * Gets the current list of size gradients.
  16676. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16677. * @returns the list of size gradients
  16678. */
  16679. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16680. /**
  16681. * Gets the current list of color remap gradients.
  16682. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16683. * @returns the list of color remap gradients
  16684. */
  16685. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16686. /**
  16687. * Gets the current list of alpha remap gradients.
  16688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16689. * @returns the list of alpha remap gradients
  16690. */
  16691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16692. /**
  16693. * Gets the current list of life time gradients.
  16694. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16695. * @returns the list of life time gradients
  16696. */
  16697. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16698. /**
  16699. * Gets the current list of angular speed gradients.
  16700. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16701. * @returns the list of angular speed gradients
  16702. */
  16703. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16704. /**
  16705. * Gets the current list of velocity gradients.
  16706. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16707. * @returns the list of velocity gradients
  16708. */
  16709. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16710. /**
  16711. * Gets the current list of start size gradients.
  16712. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16713. * @returns the list of start size gradients
  16714. */
  16715. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16716. /**
  16717. * Gets the current list of emit rate gradients.
  16718. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16719. * @returns the list of emit rate gradients
  16720. */
  16721. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16722. /**
  16723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16725. */
  16726. direction1: Vector3;
  16727. /**
  16728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16729. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16730. */
  16731. direction2: Vector3;
  16732. /**
  16733. * 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.
  16734. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16735. */
  16736. minEmitBox: Vector3;
  16737. /**
  16738. * 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.
  16739. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16740. */
  16741. maxEmitBox: Vector3;
  16742. /**
  16743. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16744. */
  16745. color1: Color4;
  16746. /**
  16747. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16748. */
  16749. color2: Color4;
  16750. /**
  16751. * Color the particle will have at the end of its lifetime
  16752. */
  16753. colorDead: Color4;
  16754. /**
  16755. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16756. */
  16757. textureMask: Color4;
  16758. /**
  16759. * The particle emitter type defines the emitter used by the particle system.
  16760. * It can be for example box, sphere, or cone...
  16761. */
  16762. particleEmitterType: IParticleEmitterType;
  16763. /** @hidden */
  16764. _isSubEmitter: boolean;
  16765. /**
  16766. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16767. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16768. */
  16769. billboardMode: number;
  16770. protected _isBillboardBased: boolean;
  16771. /**
  16772. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16773. */
  16774. isBillboardBased: boolean;
  16775. /**
  16776. * The scene the particle system belongs to.
  16777. */
  16778. protected _scene: Scene;
  16779. /**
  16780. * Local cache of defines for image processing.
  16781. */
  16782. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16783. /**
  16784. * Default configuration related to image processing available in the standard Material.
  16785. */
  16786. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16787. /**
  16788. * Gets the image processing configuration used either in this material.
  16789. */
  16790. /**
  16791. * Sets the Default image processing configuration used either in the this material.
  16792. *
  16793. * If sets to null, the scene one is in use.
  16794. */
  16795. imageProcessingConfiguration: ImageProcessingConfiguration;
  16796. /**
  16797. * Attaches a new image processing configuration to the Standard Material.
  16798. * @param configuration
  16799. */
  16800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16801. /** @hidden */
  16802. protected _reset(): void;
  16803. /** @hidden */
  16804. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16805. /**
  16806. * Instantiates a particle system.
  16807. * 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.
  16808. * @param name The name of the particle system
  16809. */
  16810. constructor(name: string);
  16811. /**
  16812. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16815. * @returns the emitter
  16816. */
  16817. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16818. /**
  16819. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16820. * @param radius The radius of the hemisphere to emit from
  16821. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16822. * @returns the emitter
  16823. */
  16824. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16825. /**
  16826. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16827. * @param radius The radius of the sphere to emit from
  16828. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16829. * @returns the emitter
  16830. */
  16831. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16832. /**
  16833. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16834. * @param radius The radius of the sphere to emit from
  16835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16837. * @returns the emitter
  16838. */
  16839. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16840. /**
  16841. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16842. * @param radius The radius of the emission cylinder
  16843. * @param height The height of the emission cylinder
  16844. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16845. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16846. * @returns the emitter
  16847. */
  16848. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16849. /**
  16850. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16851. * @param radius The radius of the cylinder to emit from
  16852. * @param height The height of the emission cylinder
  16853. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16856. * @returns the emitter
  16857. */
  16858. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16859. /**
  16860. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16861. * @param radius The radius of the cone to emit from
  16862. * @param angle The base angle of the cone
  16863. * @returns the emitter
  16864. */
  16865. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16866. /**
  16867. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16870. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16871. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16872. * @returns the emitter
  16873. */
  16874. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16875. }
  16876. }
  16877. declare module BABYLON {
  16878. /**
  16879. * Type of sub emitter
  16880. */
  16881. export enum SubEmitterType {
  16882. /**
  16883. * Attached to the particle over it's lifetime
  16884. */
  16885. ATTACHED = 0,
  16886. /**
  16887. * Created when the particle dies
  16888. */
  16889. END = 1
  16890. }
  16891. /**
  16892. * Sub emitter class used to emit particles from an existing particle
  16893. */
  16894. export class SubEmitter {
  16895. /**
  16896. * the particle system to be used by the sub emitter
  16897. */
  16898. particleSystem: ParticleSystem;
  16899. /**
  16900. * Type of the submitter (Default: END)
  16901. */
  16902. type: SubEmitterType;
  16903. /**
  16904. * 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)
  16905. * Note: This only is supported when using an emitter of type Mesh
  16906. */
  16907. inheritDirection: boolean;
  16908. /**
  16909. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16910. */
  16911. inheritedVelocityAmount: number;
  16912. /**
  16913. * Creates a sub emitter
  16914. * @param particleSystem the particle system to be used by the sub emitter
  16915. */
  16916. constructor(
  16917. /**
  16918. * the particle system to be used by the sub emitter
  16919. */
  16920. particleSystem: ParticleSystem);
  16921. /**
  16922. * Clones the sub emitter
  16923. * @returns the cloned sub emitter
  16924. */
  16925. clone(): SubEmitter;
  16926. /**
  16927. * Serialize current object to a JSON object
  16928. * @returns the serialized object
  16929. */
  16930. serialize(): any;
  16931. /** @hidden */
  16932. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16933. /**
  16934. * Creates a new SubEmitter from a serialized JSON version
  16935. * @param serializationObject defines the JSON object to read from
  16936. * @param scene defines the hosting scene
  16937. * @param rootUrl defines the rootUrl for data loading
  16938. * @returns a new SubEmitter
  16939. */
  16940. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16941. /** Release associated resources */
  16942. dispose(): void;
  16943. }
  16944. }
  16945. declare module BABYLON {
  16946. /** @hidden */
  16947. export var clipPlaneFragmentDeclaration: {
  16948. name: string;
  16949. shader: string;
  16950. };
  16951. }
  16952. declare module BABYLON {
  16953. /** @hidden */
  16954. export var imageProcessingDeclaration: {
  16955. name: string;
  16956. shader: string;
  16957. };
  16958. }
  16959. declare module BABYLON {
  16960. /** @hidden */
  16961. export var imageProcessingFunctions: {
  16962. name: string;
  16963. shader: string;
  16964. };
  16965. }
  16966. declare module BABYLON {
  16967. /** @hidden */
  16968. export var clipPlaneFragment: {
  16969. name: string;
  16970. shader: string;
  16971. };
  16972. }
  16973. declare module BABYLON {
  16974. /** @hidden */
  16975. export var particlesPixelShader: {
  16976. name: string;
  16977. shader: string;
  16978. };
  16979. }
  16980. declare module BABYLON {
  16981. /** @hidden */
  16982. export var clipPlaneVertexDeclaration: {
  16983. name: string;
  16984. shader: string;
  16985. };
  16986. }
  16987. declare module BABYLON {
  16988. /** @hidden */
  16989. export var clipPlaneVertex: {
  16990. name: string;
  16991. shader: string;
  16992. };
  16993. }
  16994. declare module BABYLON {
  16995. /** @hidden */
  16996. export var particlesVertexShader: {
  16997. name: string;
  16998. shader: string;
  16999. };
  17000. }
  17001. declare module BABYLON {
  17002. /**
  17003. * This represents a particle system in Babylon.
  17004. * 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.
  17005. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17006. * @example https://doc.babylonjs.com/babylon101/particles
  17007. */
  17008. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17009. /**
  17010. * Billboard mode will only apply to Y axis
  17011. */
  17012. static readonly BILLBOARDMODE_Y: number;
  17013. /**
  17014. * Billboard mode will apply to all axes
  17015. */
  17016. static readonly BILLBOARDMODE_ALL: number;
  17017. /**
  17018. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17019. */
  17020. static readonly BILLBOARDMODE_STRETCHED: number;
  17021. /**
  17022. * This function can be defined to provide custom update for active particles.
  17023. * This function will be called instead of regular update (age, position, color, etc.).
  17024. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17025. */
  17026. updateFunction: (particles: Particle[]) => void;
  17027. private _emitterWorldMatrix;
  17028. /**
  17029. * This function can be defined to specify initial direction for every new particle.
  17030. * It by default use the emitterType defined function
  17031. */
  17032. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17033. /**
  17034. * This function can be defined to specify initial position for every new particle.
  17035. * It by default use the emitterType defined function
  17036. */
  17037. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17038. /**
  17039. * @hidden
  17040. */
  17041. _inheritedVelocityOffset: Vector3;
  17042. /**
  17043. * An event triggered when the system is disposed
  17044. */
  17045. onDisposeObservable: Observable<ParticleSystem>;
  17046. private _onDisposeObserver;
  17047. /**
  17048. * Sets a callback that will be triggered when the system is disposed
  17049. */
  17050. onDispose: () => void;
  17051. private _particles;
  17052. private _epsilon;
  17053. private _capacity;
  17054. private _stockParticles;
  17055. private _newPartsExcess;
  17056. private _vertexData;
  17057. private _vertexBuffer;
  17058. private _vertexBuffers;
  17059. private _spriteBuffer;
  17060. private _indexBuffer;
  17061. private _effect;
  17062. private _customEffect;
  17063. private _cachedDefines;
  17064. private _scaledColorStep;
  17065. private _colorDiff;
  17066. private _scaledDirection;
  17067. private _scaledGravity;
  17068. private _currentRenderId;
  17069. private _alive;
  17070. private _useInstancing;
  17071. private _started;
  17072. private _stopped;
  17073. private _actualFrame;
  17074. private _scaledUpdateSpeed;
  17075. private _vertexBufferSize;
  17076. /** @hidden */
  17077. _currentEmitRateGradient: Nullable<FactorGradient>;
  17078. /** @hidden */
  17079. _currentEmitRate1: number;
  17080. /** @hidden */
  17081. _currentEmitRate2: number;
  17082. /** @hidden */
  17083. _currentStartSizeGradient: Nullable<FactorGradient>;
  17084. /** @hidden */
  17085. _currentStartSize1: number;
  17086. /** @hidden */
  17087. _currentStartSize2: number;
  17088. private readonly _rawTextureWidth;
  17089. private _rampGradientsTexture;
  17090. private _useRampGradients;
  17091. /** Gets or sets a boolean indicating that ramp gradients must be used
  17092. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17093. */
  17094. useRampGradients: boolean;
  17095. /**
  17096. * 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.
  17097. * 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: [])
  17098. */
  17099. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17100. private _subEmitters;
  17101. /**
  17102. * @hidden
  17103. * If the particle systems emitter should be disposed when the particle system is disposed
  17104. */
  17105. _disposeEmitterOnDispose: boolean;
  17106. /**
  17107. * The current active Sub-systems, this property is used by the root particle system only.
  17108. */
  17109. activeSubSystems: Array<ParticleSystem>;
  17110. private _rootParticleSystem;
  17111. /**
  17112. * Gets the current list of active particles
  17113. */
  17114. readonly particles: Particle[];
  17115. /**
  17116. * Returns the string "ParticleSystem"
  17117. * @returns a string containing the class name
  17118. */
  17119. getClassName(): string;
  17120. /**
  17121. * Instantiates a particle system.
  17122. * 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.
  17123. * @param name The name of the particle system
  17124. * @param capacity The max number of particles alive at the same time
  17125. * @param scene The scene the particle system belongs to
  17126. * @param customEffect a custom effect used to change the way particles are rendered by default
  17127. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17128. * @param epsilon Offset used to render the particles
  17129. */
  17130. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17131. private _addFactorGradient;
  17132. private _removeFactorGradient;
  17133. /**
  17134. * Adds a new life time gradient
  17135. * @param gradient defines the gradient to use (between 0 and 1)
  17136. * @param factor defines the life time factor to affect to the specified gradient
  17137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17138. * @returns the current particle system
  17139. */
  17140. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17141. /**
  17142. * Remove a specific life time gradient
  17143. * @param gradient defines the gradient to remove
  17144. * @returns the current particle system
  17145. */
  17146. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17147. /**
  17148. * Adds a new size gradient
  17149. * @param gradient defines the gradient to use (between 0 and 1)
  17150. * @param factor defines the size factor to affect to the specified gradient
  17151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17152. * @returns the current particle system
  17153. */
  17154. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17155. /**
  17156. * Remove a specific size gradient
  17157. * @param gradient defines the gradient to remove
  17158. * @returns the current particle system
  17159. */
  17160. removeSizeGradient(gradient: number): IParticleSystem;
  17161. /**
  17162. * Adds a new color remap gradient
  17163. * @param gradient defines the gradient to use (between 0 and 1)
  17164. * @param min defines the color remap minimal range
  17165. * @param max defines the color remap maximal range
  17166. * @returns the current particle system
  17167. */
  17168. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17169. /**
  17170. * Remove a specific color remap gradient
  17171. * @param gradient defines the gradient to remove
  17172. * @returns the current particle system
  17173. */
  17174. removeColorRemapGradient(gradient: number): IParticleSystem;
  17175. /**
  17176. * Adds a new alpha remap gradient
  17177. * @param gradient defines the gradient to use (between 0 and 1)
  17178. * @param min defines the alpha remap minimal range
  17179. * @param max defines the alpha remap maximal range
  17180. * @returns the current particle system
  17181. */
  17182. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17183. /**
  17184. * Remove a specific alpha remap gradient
  17185. * @param gradient defines the gradient to remove
  17186. * @returns the current particle system
  17187. */
  17188. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17189. /**
  17190. * Adds a new angular speed gradient
  17191. * @param gradient defines the gradient to use (between 0 and 1)
  17192. * @param factor defines the angular speed to affect to the specified gradient
  17193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17194. * @returns the current particle system
  17195. */
  17196. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17197. /**
  17198. * Remove a specific angular speed gradient
  17199. * @param gradient defines the gradient to remove
  17200. * @returns the current particle system
  17201. */
  17202. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17203. /**
  17204. * Adds a new velocity gradient
  17205. * @param gradient defines the gradient to use (between 0 and 1)
  17206. * @param factor defines the velocity to affect to the specified gradient
  17207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17208. * @returns the current particle system
  17209. */
  17210. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17211. /**
  17212. * Remove a specific velocity gradient
  17213. * @param gradient defines the gradient to remove
  17214. * @returns the current particle system
  17215. */
  17216. removeVelocityGradient(gradient: number): IParticleSystem;
  17217. /**
  17218. * Adds a new limit velocity gradient
  17219. * @param gradient defines the gradient to use (between 0 and 1)
  17220. * @param factor defines the limit velocity value to affect to the specified gradient
  17221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17222. * @returns the current particle system
  17223. */
  17224. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17225. /**
  17226. * Remove a specific limit velocity gradient
  17227. * @param gradient defines the gradient to remove
  17228. * @returns the current particle system
  17229. */
  17230. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17231. /**
  17232. * Adds a new drag gradient
  17233. * @param gradient defines the gradient to use (between 0 and 1)
  17234. * @param factor defines the drag value to affect to the specified gradient
  17235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17236. * @returns the current particle system
  17237. */
  17238. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17239. /**
  17240. * Remove a specific drag gradient
  17241. * @param gradient defines the gradient to remove
  17242. * @returns the current particle system
  17243. */
  17244. removeDragGradient(gradient: number): IParticleSystem;
  17245. /**
  17246. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17247. * @param gradient defines the gradient to use (between 0 and 1)
  17248. * @param factor defines the emit rate value to affect to the specified gradient
  17249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17250. * @returns the current particle system
  17251. */
  17252. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17253. /**
  17254. * Remove a specific emit rate gradient
  17255. * @param gradient defines the gradient to remove
  17256. * @returns the current particle system
  17257. */
  17258. removeEmitRateGradient(gradient: number): IParticleSystem;
  17259. /**
  17260. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17261. * @param gradient defines the gradient to use (between 0 and 1)
  17262. * @param factor defines the start size value to affect to the specified gradient
  17263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17264. * @returns the current particle system
  17265. */
  17266. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17267. /**
  17268. * Remove a specific start size gradient
  17269. * @param gradient defines the gradient to remove
  17270. * @returns the current particle system
  17271. */
  17272. removeStartSizeGradient(gradient: number): IParticleSystem;
  17273. private _createRampGradientTexture;
  17274. /**
  17275. * Gets the current list of ramp gradients.
  17276. * You must use addRampGradient and removeRampGradient to udpate this list
  17277. * @returns the list of ramp gradients
  17278. */
  17279. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17280. /**
  17281. * Adds a new ramp gradient used to remap particle colors
  17282. * @param gradient defines the gradient to use (between 0 and 1)
  17283. * @param color defines the color to affect to the specified gradient
  17284. * @returns the current particle system
  17285. */
  17286. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17287. /**
  17288. * Remove a specific ramp gradient
  17289. * @param gradient defines the gradient to remove
  17290. * @returns the current particle system
  17291. */
  17292. removeRampGradient(gradient: number): ParticleSystem;
  17293. /**
  17294. * Adds a new color gradient
  17295. * @param gradient defines the gradient to use (between 0 and 1)
  17296. * @param color1 defines the color to affect to the specified gradient
  17297. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17298. * @returns this particle system
  17299. */
  17300. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17301. /**
  17302. * Remove a specific color gradient
  17303. * @param gradient defines the gradient to remove
  17304. * @returns this particle system
  17305. */
  17306. removeColorGradient(gradient: number): IParticleSystem;
  17307. private _fetchR;
  17308. protected _reset(): void;
  17309. private _resetEffect;
  17310. private _createVertexBuffers;
  17311. private _createIndexBuffer;
  17312. /**
  17313. * Gets the maximum number of particles active at the same time.
  17314. * @returns The max number of active particles.
  17315. */
  17316. getCapacity(): number;
  17317. /**
  17318. * Gets whether there are still active particles in the system.
  17319. * @returns True if it is alive, otherwise false.
  17320. */
  17321. isAlive(): boolean;
  17322. /**
  17323. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17324. * @returns True if it has been started, otherwise false.
  17325. */
  17326. isStarted(): boolean;
  17327. private _prepareSubEmitterInternalArray;
  17328. /**
  17329. * Starts the particle system and begins to emit
  17330. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17331. */
  17332. start(delay?: number): void;
  17333. /**
  17334. * Stops the particle system.
  17335. * @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.
  17336. */
  17337. stop(stopSubEmitters?: boolean): void;
  17338. /**
  17339. * Remove all active particles
  17340. */
  17341. reset(): void;
  17342. /**
  17343. * @hidden (for internal use only)
  17344. */
  17345. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17346. /**
  17347. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17348. * Its lifetime will start back at 0.
  17349. */
  17350. recycleParticle: (particle: Particle) => void;
  17351. private _stopSubEmitters;
  17352. private _createParticle;
  17353. private _removeFromRoot;
  17354. private _emitFromParticle;
  17355. private _update;
  17356. /** @hidden */
  17357. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17358. /** @hidden */
  17359. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17360. /** @hidden */
  17361. private _getEffect;
  17362. /**
  17363. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17364. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17365. */
  17366. animate(preWarmOnly?: boolean): void;
  17367. private _appendParticleVertices;
  17368. /**
  17369. * Rebuilds the particle system.
  17370. */
  17371. rebuild(): void;
  17372. /**
  17373. * Is this system ready to be used/rendered
  17374. * @return true if the system is ready
  17375. */
  17376. isReady(): boolean;
  17377. private _render;
  17378. /**
  17379. * Renders the particle system in its current state.
  17380. * @returns the current number of particles
  17381. */
  17382. render(): number;
  17383. /**
  17384. * Disposes the particle system and free the associated resources
  17385. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17386. */
  17387. dispose(disposeTexture?: boolean): void;
  17388. /**
  17389. * Clones the particle system.
  17390. * @param name The name of the cloned object
  17391. * @param newEmitter The new emitter to use
  17392. * @returns the cloned particle system
  17393. */
  17394. clone(name: string, newEmitter: any): ParticleSystem;
  17395. /**
  17396. * Serializes the particle system to a JSON object.
  17397. * @returns the JSON object
  17398. */
  17399. serialize(): any;
  17400. /** @hidden */
  17401. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17402. /** @hidden */
  17403. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17404. /**
  17405. * Parses a JSON object to create a particle system.
  17406. * @param parsedParticleSystem The JSON object to parse
  17407. * @param scene The scene to create the particle system in
  17408. * @param rootUrl The root url to use to load external dependencies like texture
  17409. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17410. * @returns the Parsed particle system
  17411. */
  17412. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17413. }
  17414. }
  17415. declare module BABYLON {
  17416. /**
  17417. * A particle represents one of the element emitted by a particle system.
  17418. * This is mainly define by its coordinates, direction, velocity and age.
  17419. */
  17420. export class Particle {
  17421. /**
  17422. * The particle system the particle belongs to.
  17423. */
  17424. particleSystem: ParticleSystem;
  17425. private static _Count;
  17426. /**
  17427. * Unique ID of the particle
  17428. */
  17429. id: number;
  17430. /**
  17431. * The world position of the particle in the scene.
  17432. */
  17433. position: Vector3;
  17434. /**
  17435. * The world direction of the particle in the scene.
  17436. */
  17437. direction: Vector3;
  17438. /**
  17439. * The color of the particle.
  17440. */
  17441. color: Color4;
  17442. /**
  17443. * The color change of the particle per step.
  17444. */
  17445. colorStep: Color4;
  17446. /**
  17447. * Defines how long will the life of the particle be.
  17448. */
  17449. lifeTime: number;
  17450. /**
  17451. * The current age of the particle.
  17452. */
  17453. age: number;
  17454. /**
  17455. * The current size of the particle.
  17456. */
  17457. size: number;
  17458. /**
  17459. * The current scale of the particle.
  17460. */
  17461. scale: Vector2;
  17462. /**
  17463. * The current angle of the particle.
  17464. */
  17465. angle: number;
  17466. /**
  17467. * Defines how fast is the angle changing.
  17468. */
  17469. angularSpeed: number;
  17470. /**
  17471. * Defines the cell index used by the particle to be rendered from a sprite.
  17472. */
  17473. cellIndex: number;
  17474. /**
  17475. * The information required to support color remapping
  17476. */
  17477. remapData: Vector4;
  17478. /** @hidden */
  17479. _randomCellOffset?: number;
  17480. /** @hidden */
  17481. _initialDirection: Nullable<Vector3>;
  17482. /** @hidden */
  17483. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17484. /** @hidden */
  17485. _initialStartSpriteCellID: number;
  17486. /** @hidden */
  17487. _initialEndSpriteCellID: number;
  17488. /** @hidden */
  17489. _currentColorGradient: Nullable<ColorGradient>;
  17490. /** @hidden */
  17491. _currentColor1: Color4;
  17492. /** @hidden */
  17493. _currentColor2: Color4;
  17494. /** @hidden */
  17495. _currentSizeGradient: Nullable<FactorGradient>;
  17496. /** @hidden */
  17497. _currentSize1: number;
  17498. /** @hidden */
  17499. _currentSize2: number;
  17500. /** @hidden */
  17501. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17502. /** @hidden */
  17503. _currentAngularSpeed1: number;
  17504. /** @hidden */
  17505. _currentAngularSpeed2: number;
  17506. /** @hidden */
  17507. _currentVelocityGradient: Nullable<FactorGradient>;
  17508. /** @hidden */
  17509. _currentVelocity1: number;
  17510. /** @hidden */
  17511. _currentVelocity2: number;
  17512. /** @hidden */
  17513. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17514. /** @hidden */
  17515. _currentLimitVelocity1: number;
  17516. /** @hidden */
  17517. _currentLimitVelocity2: number;
  17518. /** @hidden */
  17519. _currentDragGradient: Nullable<FactorGradient>;
  17520. /** @hidden */
  17521. _currentDrag1: number;
  17522. /** @hidden */
  17523. _currentDrag2: number;
  17524. /** @hidden */
  17525. _randomNoiseCoordinates1: Vector3;
  17526. /** @hidden */
  17527. _randomNoiseCoordinates2: Vector3;
  17528. /**
  17529. * Creates a new instance Particle
  17530. * @param particleSystem the particle system the particle belongs to
  17531. */
  17532. constructor(
  17533. /**
  17534. * The particle system the particle belongs to.
  17535. */
  17536. particleSystem: ParticleSystem);
  17537. private updateCellInfoFromSystem;
  17538. /**
  17539. * Defines how the sprite cell index is updated for the particle
  17540. */
  17541. updateCellIndex(): void;
  17542. /** @hidden */
  17543. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17544. /** @hidden */
  17545. _inheritParticleInfoToSubEmitters(): void;
  17546. /** @hidden */
  17547. _reset(): void;
  17548. /**
  17549. * Copy the properties of particle to another one.
  17550. * @param other the particle to copy the information to.
  17551. */
  17552. copyTo(other: Particle): void;
  17553. }
  17554. }
  17555. declare module BABYLON {
  17556. /**
  17557. * Particle emitter represents a volume emitting particles.
  17558. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17559. */
  17560. export interface IParticleEmitterType {
  17561. /**
  17562. * Called by the particle System when the direction is computed for the created particle.
  17563. * @param worldMatrix is the world matrix of the particle system
  17564. * @param directionToUpdate is the direction vector to update with the result
  17565. * @param particle is the particle we are computed the direction for
  17566. */
  17567. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17568. /**
  17569. * Called by the particle System when the position is computed for the created particle.
  17570. * @param worldMatrix is the world matrix of the particle system
  17571. * @param positionToUpdate is the position vector to update with the result
  17572. * @param particle is the particle we are computed the position for
  17573. */
  17574. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17575. /**
  17576. * Clones the current emitter and returns a copy of it
  17577. * @returns the new emitter
  17578. */
  17579. clone(): IParticleEmitterType;
  17580. /**
  17581. * Called by the GPUParticleSystem to setup the update shader
  17582. * @param effect defines the update shader
  17583. */
  17584. applyToShader(effect: Effect): void;
  17585. /**
  17586. * Returns a string to use to update the GPU particles update shader
  17587. * @returns the effect defines string
  17588. */
  17589. getEffectDefines(): string;
  17590. /**
  17591. * Returns a string representing the class name
  17592. * @returns a string containing the class name
  17593. */
  17594. getClassName(): string;
  17595. /**
  17596. * Serializes the particle system to a JSON object.
  17597. * @returns the JSON object
  17598. */
  17599. serialize(): any;
  17600. /**
  17601. * Parse properties from a JSON object
  17602. * @param serializationObject defines the JSON object
  17603. */
  17604. parse(serializationObject: any): void;
  17605. }
  17606. }
  17607. declare module BABYLON {
  17608. /**
  17609. * Particle emitter emitting particles from the inside of a box.
  17610. * It emits the particles randomly between 2 given directions.
  17611. */
  17612. export class BoxParticleEmitter implements IParticleEmitterType {
  17613. /**
  17614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17615. */
  17616. direction1: Vector3;
  17617. /**
  17618. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17619. */
  17620. direction2: Vector3;
  17621. /**
  17622. * 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.
  17623. */
  17624. minEmitBox: Vector3;
  17625. /**
  17626. * 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.
  17627. */
  17628. maxEmitBox: Vector3;
  17629. /**
  17630. * Creates a new instance BoxParticleEmitter
  17631. */
  17632. constructor();
  17633. /**
  17634. * Called by the particle System when the direction is computed for the created particle.
  17635. * @param worldMatrix is the world matrix of the particle system
  17636. * @param directionToUpdate is the direction vector to update with the result
  17637. * @param particle is the particle we are computed the direction for
  17638. */
  17639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17640. /**
  17641. * Called by the particle System when the position is computed for the created particle.
  17642. * @param worldMatrix is the world matrix of the particle system
  17643. * @param positionToUpdate is the position vector to update with the result
  17644. * @param particle is the particle we are computed the position for
  17645. */
  17646. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17647. /**
  17648. * Clones the current emitter and returns a copy of it
  17649. * @returns the new emitter
  17650. */
  17651. clone(): BoxParticleEmitter;
  17652. /**
  17653. * Called by the GPUParticleSystem to setup the update shader
  17654. * @param effect defines the update shader
  17655. */
  17656. applyToShader(effect: Effect): void;
  17657. /**
  17658. * Returns a string to use to update the GPU particles update shader
  17659. * @returns a string containng the defines string
  17660. */
  17661. getEffectDefines(): string;
  17662. /**
  17663. * Returns the string "BoxParticleEmitter"
  17664. * @returns a string containing the class name
  17665. */
  17666. getClassName(): string;
  17667. /**
  17668. * Serializes the particle system to a JSON object.
  17669. * @returns the JSON object
  17670. */
  17671. serialize(): any;
  17672. /**
  17673. * Parse properties from a JSON object
  17674. * @param serializationObject defines the JSON object
  17675. */
  17676. parse(serializationObject: any): void;
  17677. }
  17678. }
  17679. declare module BABYLON {
  17680. /**
  17681. * Particle emitter emitting particles from the inside of a cone.
  17682. * It emits the particles alongside the cone volume from the base to the particle.
  17683. * The emission direction might be randomized.
  17684. */
  17685. export class ConeParticleEmitter implements IParticleEmitterType {
  17686. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17687. directionRandomizer: number;
  17688. private _radius;
  17689. private _angle;
  17690. private _height;
  17691. /**
  17692. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17693. */
  17694. radiusRange: number;
  17695. /**
  17696. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17697. */
  17698. heightRange: number;
  17699. /**
  17700. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17701. */
  17702. emitFromSpawnPointOnly: boolean;
  17703. /**
  17704. * Gets or sets the radius of the emission cone
  17705. */
  17706. radius: number;
  17707. /**
  17708. * Gets or sets the angle of the emission cone
  17709. */
  17710. angle: number;
  17711. private _buildHeight;
  17712. /**
  17713. * Creates a new instance ConeParticleEmitter
  17714. * @param radius the radius of the emission cone (1 by default)
  17715. * @param angle the cone base angle (PI by default)
  17716. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17717. */
  17718. constructor(radius?: number, angle?: number,
  17719. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17720. directionRandomizer?: number);
  17721. /**
  17722. * Called by the particle System when the direction is computed for the created particle.
  17723. * @param worldMatrix is the world matrix of the particle system
  17724. * @param directionToUpdate is the direction vector to update with the result
  17725. * @param particle is the particle we are computed the direction for
  17726. */
  17727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17728. /**
  17729. * Called by the particle System when the position is computed for the created particle.
  17730. * @param worldMatrix is the world matrix of the particle system
  17731. * @param positionToUpdate is the position vector to update with the result
  17732. * @param particle is the particle we are computed the position for
  17733. */
  17734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17735. /**
  17736. * Clones the current emitter and returns a copy of it
  17737. * @returns the new emitter
  17738. */
  17739. clone(): ConeParticleEmitter;
  17740. /**
  17741. * Called by the GPUParticleSystem to setup the update shader
  17742. * @param effect defines the update shader
  17743. */
  17744. applyToShader(effect: Effect): void;
  17745. /**
  17746. * Returns a string to use to update the GPU particles update shader
  17747. * @returns a string containng the defines string
  17748. */
  17749. getEffectDefines(): string;
  17750. /**
  17751. * Returns the string "ConeParticleEmitter"
  17752. * @returns a string containing the class name
  17753. */
  17754. getClassName(): string;
  17755. /**
  17756. * Serializes the particle system to a JSON object.
  17757. * @returns the JSON object
  17758. */
  17759. serialize(): any;
  17760. /**
  17761. * Parse properties from a JSON object
  17762. * @param serializationObject defines the JSON object
  17763. */
  17764. parse(serializationObject: any): void;
  17765. }
  17766. }
  17767. declare module BABYLON {
  17768. /**
  17769. * Particle emitter emitting particles from the inside of a cylinder.
  17770. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17771. */
  17772. export class CylinderParticleEmitter implements IParticleEmitterType {
  17773. /**
  17774. * The radius of the emission cylinder.
  17775. */
  17776. radius: number;
  17777. /**
  17778. * The height of the emission cylinder.
  17779. */
  17780. height: number;
  17781. /**
  17782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17783. */
  17784. radiusRange: number;
  17785. /**
  17786. * How much to randomize the particle direction [0-1].
  17787. */
  17788. directionRandomizer: number;
  17789. /**
  17790. * Creates a new instance CylinderParticleEmitter
  17791. * @param radius the radius of the emission cylinder (1 by default)
  17792. * @param height the height of the emission cylinder (1 by default)
  17793. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17794. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17795. */
  17796. constructor(
  17797. /**
  17798. * The radius of the emission cylinder.
  17799. */
  17800. radius?: number,
  17801. /**
  17802. * The height of the emission cylinder.
  17803. */
  17804. height?: number,
  17805. /**
  17806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17807. */
  17808. radiusRange?: number,
  17809. /**
  17810. * How much to randomize the particle direction [0-1].
  17811. */
  17812. directionRandomizer?: number);
  17813. /**
  17814. * Called by the particle System when the direction is computed for the created particle.
  17815. * @param worldMatrix is the world matrix of the particle system
  17816. * @param directionToUpdate is the direction vector to update with the result
  17817. * @param particle is the particle we are computed the direction for
  17818. */
  17819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17820. /**
  17821. * Called by the particle System when the position is computed for the created particle.
  17822. * @param worldMatrix is the world matrix of the particle system
  17823. * @param positionToUpdate is the position vector to update with the result
  17824. * @param particle is the particle we are computed the position for
  17825. */
  17826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17827. /**
  17828. * Clones the current emitter and returns a copy of it
  17829. * @returns the new emitter
  17830. */
  17831. clone(): CylinderParticleEmitter;
  17832. /**
  17833. * Called by the GPUParticleSystem to setup the update shader
  17834. * @param effect defines the update shader
  17835. */
  17836. applyToShader(effect: Effect): void;
  17837. /**
  17838. * Returns a string to use to update the GPU particles update shader
  17839. * @returns a string containng the defines string
  17840. */
  17841. getEffectDefines(): string;
  17842. /**
  17843. * Returns the string "CylinderParticleEmitter"
  17844. * @returns a string containing the class name
  17845. */
  17846. getClassName(): string;
  17847. /**
  17848. * Serializes the particle system to a JSON object.
  17849. * @returns the JSON object
  17850. */
  17851. serialize(): any;
  17852. /**
  17853. * Parse properties from a JSON object
  17854. * @param serializationObject defines the JSON object
  17855. */
  17856. parse(serializationObject: any): void;
  17857. }
  17858. /**
  17859. * Particle emitter emitting particles from the inside of a cylinder.
  17860. * It emits the particles randomly between two vectors.
  17861. */
  17862. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17863. /**
  17864. * The min limit of the emission direction.
  17865. */
  17866. direction1: Vector3;
  17867. /**
  17868. * The max limit of the emission direction.
  17869. */
  17870. direction2: Vector3;
  17871. /**
  17872. * Creates a new instance CylinderDirectedParticleEmitter
  17873. * @param radius the radius of the emission cylinder (1 by default)
  17874. * @param height the height of the emission cylinder (1 by default)
  17875. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17876. * @param direction1 the min limit of the emission direction (up vector by default)
  17877. * @param direction2 the max limit of the emission direction (up vector by default)
  17878. */
  17879. constructor(radius?: number, height?: number, radiusRange?: number,
  17880. /**
  17881. * The min limit of the emission direction.
  17882. */
  17883. direction1?: Vector3,
  17884. /**
  17885. * The max limit of the emission direction.
  17886. */
  17887. direction2?: Vector3);
  17888. /**
  17889. * Called by the particle System when the direction is computed for the created particle.
  17890. * @param worldMatrix is the world matrix of the particle system
  17891. * @param directionToUpdate is the direction vector to update with the result
  17892. * @param particle is the particle we are computed the direction for
  17893. */
  17894. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17895. /**
  17896. * Clones the current emitter and returns a copy of it
  17897. * @returns the new emitter
  17898. */
  17899. clone(): CylinderDirectedParticleEmitter;
  17900. /**
  17901. * Called by the GPUParticleSystem to setup the update shader
  17902. * @param effect defines the update shader
  17903. */
  17904. applyToShader(effect: Effect): void;
  17905. /**
  17906. * Returns a string to use to update the GPU particles update shader
  17907. * @returns a string containng the defines string
  17908. */
  17909. getEffectDefines(): string;
  17910. /**
  17911. * Returns the string "CylinderDirectedParticleEmitter"
  17912. * @returns a string containing the class name
  17913. */
  17914. getClassName(): string;
  17915. /**
  17916. * Serializes the particle system to a JSON object.
  17917. * @returns the JSON object
  17918. */
  17919. serialize(): any;
  17920. /**
  17921. * Parse properties from a JSON object
  17922. * @param serializationObject defines the JSON object
  17923. */
  17924. parse(serializationObject: any): void;
  17925. }
  17926. }
  17927. declare module BABYLON {
  17928. /**
  17929. * Particle emitter emitting particles from the inside of a hemisphere.
  17930. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17931. */
  17932. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17933. /**
  17934. * The radius of the emission hemisphere.
  17935. */
  17936. radius: number;
  17937. /**
  17938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17939. */
  17940. radiusRange: number;
  17941. /**
  17942. * How much to randomize the particle direction [0-1].
  17943. */
  17944. directionRandomizer: number;
  17945. /**
  17946. * Creates a new instance HemisphericParticleEmitter
  17947. * @param radius the radius of the emission hemisphere (1 by default)
  17948. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17950. */
  17951. constructor(
  17952. /**
  17953. * The radius of the emission hemisphere.
  17954. */
  17955. radius?: number,
  17956. /**
  17957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17958. */
  17959. radiusRange?: number,
  17960. /**
  17961. * How much to randomize the particle direction [0-1].
  17962. */
  17963. directionRandomizer?: number);
  17964. /**
  17965. * Called by the particle System when the direction is computed for the created particle.
  17966. * @param worldMatrix is the world matrix of the particle system
  17967. * @param directionToUpdate is the direction vector to update with the result
  17968. * @param particle is the particle we are computed the direction for
  17969. */
  17970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17971. /**
  17972. * Called by the particle System when the position is computed for the created particle.
  17973. * @param worldMatrix is the world matrix of the particle system
  17974. * @param positionToUpdate is the position vector to update with the result
  17975. * @param particle is the particle we are computed the position for
  17976. */
  17977. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17978. /**
  17979. * Clones the current emitter and returns a copy of it
  17980. * @returns the new emitter
  17981. */
  17982. clone(): HemisphericParticleEmitter;
  17983. /**
  17984. * Called by the GPUParticleSystem to setup the update shader
  17985. * @param effect defines the update shader
  17986. */
  17987. applyToShader(effect: Effect): void;
  17988. /**
  17989. * Returns a string to use to update the GPU particles update shader
  17990. * @returns a string containng the defines string
  17991. */
  17992. getEffectDefines(): string;
  17993. /**
  17994. * Returns the string "HemisphericParticleEmitter"
  17995. * @returns a string containing the class name
  17996. */
  17997. getClassName(): string;
  17998. /**
  17999. * Serializes the particle system to a JSON object.
  18000. * @returns the JSON object
  18001. */
  18002. serialize(): any;
  18003. /**
  18004. * Parse properties from a JSON object
  18005. * @param serializationObject defines the JSON object
  18006. */
  18007. parse(serializationObject: any): void;
  18008. }
  18009. }
  18010. declare module BABYLON {
  18011. /**
  18012. * Particle emitter emitting particles from a point.
  18013. * It emits the particles randomly between 2 given directions.
  18014. */
  18015. export class PointParticleEmitter implements IParticleEmitterType {
  18016. /**
  18017. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18018. */
  18019. direction1: Vector3;
  18020. /**
  18021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18022. */
  18023. direction2: Vector3;
  18024. /**
  18025. * Creates a new instance PointParticleEmitter
  18026. */
  18027. constructor();
  18028. /**
  18029. * Called by the particle System when the direction is computed for the created particle.
  18030. * @param worldMatrix is the world matrix of the particle system
  18031. * @param directionToUpdate is the direction vector to update with the result
  18032. * @param particle is the particle we are computed the direction for
  18033. */
  18034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18035. /**
  18036. * Called by the particle System when the position is computed for the created particle.
  18037. * @param worldMatrix is the world matrix of the particle system
  18038. * @param positionToUpdate is the position vector to update with the result
  18039. * @param particle is the particle we are computed the position for
  18040. */
  18041. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18042. /**
  18043. * Clones the current emitter and returns a copy of it
  18044. * @returns the new emitter
  18045. */
  18046. clone(): PointParticleEmitter;
  18047. /**
  18048. * Called by the GPUParticleSystem to setup the update shader
  18049. * @param effect defines the update shader
  18050. */
  18051. applyToShader(effect: Effect): void;
  18052. /**
  18053. * Returns a string to use to update the GPU particles update shader
  18054. * @returns a string containng the defines string
  18055. */
  18056. getEffectDefines(): string;
  18057. /**
  18058. * Returns the string "PointParticleEmitter"
  18059. * @returns a string containing the class name
  18060. */
  18061. getClassName(): string;
  18062. /**
  18063. * Serializes the particle system to a JSON object.
  18064. * @returns the JSON object
  18065. */
  18066. serialize(): any;
  18067. /**
  18068. * Parse properties from a JSON object
  18069. * @param serializationObject defines the JSON object
  18070. */
  18071. parse(serializationObject: any): void;
  18072. }
  18073. }
  18074. declare module BABYLON {
  18075. /**
  18076. * Particle emitter emitting particles from the inside of a sphere.
  18077. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18078. */
  18079. export class SphereParticleEmitter implements IParticleEmitterType {
  18080. /**
  18081. * The radius of the emission sphere.
  18082. */
  18083. radius: number;
  18084. /**
  18085. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18086. */
  18087. radiusRange: number;
  18088. /**
  18089. * How much to randomize the particle direction [0-1].
  18090. */
  18091. directionRandomizer: number;
  18092. /**
  18093. * Creates a new instance SphereParticleEmitter
  18094. * @param radius the radius of the emission sphere (1 by default)
  18095. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18096. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18097. */
  18098. constructor(
  18099. /**
  18100. * The radius of the emission sphere.
  18101. */
  18102. radius?: number,
  18103. /**
  18104. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18105. */
  18106. radiusRange?: number,
  18107. /**
  18108. * How much to randomize the particle direction [0-1].
  18109. */
  18110. directionRandomizer?: number);
  18111. /**
  18112. * Called by the particle System when the direction is computed for the created particle.
  18113. * @param worldMatrix is the world matrix of the particle system
  18114. * @param directionToUpdate is the direction vector to update with the result
  18115. * @param particle is the particle we are computed the direction for
  18116. */
  18117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18118. /**
  18119. * Called by the particle System when the position is computed for the created particle.
  18120. * @param worldMatrix is the world matrix of the particle system
  18121. * @param positionToUpdate is the position vector to update with the result
  18122. * @param particle is the particle we are computed the position for
  18123. */
  18124. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18125. /**
  18126. * Clones the current emitter and returns a copy of it
  18127. * @returns the new emitter
  18128. */
  18129. clone(): SphereParticleEmitter;
  18130. /**
  18131. * Called by the GPUParticleSystem to setup the update shader
  18132. * @param effect defines the update shader
  18133. */
  18134. applyToShader(effect: Effect): void;
  18135. /**
  18136. * Returns a string to use to update the GPU particles update shader
  18137. * @returns a string containng the defines string
  18138. */
  18139. getEffectDefines(): string;
  18140. /**
  18141. * Returns the string "SphereParticleEmitter"
  18142. * @returns a string containing the class name
  18143. */
  18144. getClassName(): string;
  18145. /**
  18146. * Serializes the particle system to a JSON object.
  18147. * @returns the JSON object
  18148. */
  18149. serialize(): any;
  18150. /**
  18151. * Parse properties from a JSON object
  18152. * @param serializationObject defines the JSON object
  18153. */
  18154. parse(serializationObject: any): void;
  18155. }
  18156. /**
  18157. * Particle emitter emitting particles from the inside of a sphere.
  18158. * It emits the particles randomly between two vectors.
  18159. */
  18160. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18161. /**
  18162. * The min limit of the emission direction.
  18163. */
  18164. direction1: Vector3;
  18165. /**
  18166. * The max limit of the emission direction.
  18167. */
  18168. direction2: Vector3;
  18169. /**
  18170. * Creates a new instance SphereDirectedParticleEmitter
  18171. * @param radius the radius of the emission sphere (1 by default)
  18172. * @param direction1 the min limit of the emission direction (up vector by default)
  18173. * @param direction2 the max limit of the emission direction (up vector by default)
  18174. */
  18175. constructor(radius?: number,
  18176. /**
  18177. * The min limit of the emission direction.
  18178. */
  18179. direction1?: Vector3,
  18180. /**
  18181. * The max limit of the emission direction.
  18182. */
  18183. direction2?: Vector3);
  18184. /**
  18185. * Called by the particle System when the direction is computed for the created particle.
  18186. * @param worldMatrix is the world matrix of the particle system
  18187. * @param directionToUpdate is the direction vector to update with the result
  18188. * @param particle is the particle we are computed the direction for
  18189. */
  18190. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18191. /**
  18192. * Clones the current emitter and returns a copy of it
  18193. * @returns the new emitter
  18194. */
  18195. clone(): SphereDirectedParticleEmitter;
  18196. /**
  18197. * Called by the GPUParticleSystem to setup the update shader
  18198. * @param effect defines the update shader
  18199. */
  18200. applyToShader(effect: Effect): void;
  18201. /**
  18202. * Returns a string to use to update the GPU particles update shader
  18203. * @returns a string containng the defines string
  18204. */
  18205. getEffectDefines(): string;
  18206. /**
  18207. * Returns the string "SphereDirectedParticleEmitter"
  18208. * @returns a string containing the class name
  18209. */
  18210. getClassName(): string;
  18211. /**
  18212. * Serializes the particle system to a JSON object.
  18213. * @returns the JSON object
  18214. */
  18215. serialize(): any;
  18216. /**
  18217. * Parse properties from a JSON object
  18218. * @param serializationObject defines the JSON object
  18219. */
  18220. parse(serializationObject: any): void;
  18221. }
  18222. }
  18223. declare module BABYLON {
  18224. /**
  18225. * Interface representing a particle system in Babylon.js.
  18226. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18227. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18228. */
  18229. export interface IParticleSystem {
  18230. /**
  18231. * List of animations used by the particle system.
  18232. */
  18233. animations: Animation[];
  18234. /**
  18235. * The id of the Particle system.
  18236. */
  18237. id: string;
  18238. /**
  18239. * The name of the Particle system.
  18240. */
  18241. name: string;
  18242. /**
  18243. * The emitter represents the Mesh or position we are attaching the particle system to.
  18244. */
  18245. emitter: Nullable<AbstractMesh | Vector3>;
  18246. /**
  18247. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18248. */
  18249. isBillboardBased: boolean;
  18250. /**
  18251. * The rendering group used by the Particle system to chose when to render.
  18252. */
  18253. renderingGroupId: number;
  18254. /**
  18255. * The layer mask we are rendering the particles through.
  18256. */
  18257. layerMask: number;
  18258. /**
  18259. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18260. */
  18261. updateSpeed: number;
  18262. /**
  18263. * The amount of time the particle system is running (depends of the overall update speed).
  18264. */
  18265. targetStopDuration: number;
  18266. /**
  18267. * The texture used to render each particle. (this can be a spritesheet)
  18268. */
  18269. particleTexture: Nullable<Texture>;
  18270. /**
  18271. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18272. */
  18273. blendMode: number;
  18274. /**
  18275. * Minimum life time of emitting particles.
  18276. */
  18277. minLifeTime: number;
  18278. /**
  18279. * Maximum life time of emitting particles.
  18280. */
  18281. maxLifeTime: number;
  18282. /**
  18283. * Minimum Size of emitting particles.
  18284. */
  18285. minSize: number;
  18286. /**
  18287. * Maximum Size of emitting particles.
  18288. */
  18289. maxSize: number;
  18290. /**
  18291. * Minimum scale of emitting particles on X axis.
  18292. */
  18293. minScaleX: number;
  18294. /**
  18295. * Maximum scale of emitting particles on X axis.
  18296. */
  18297. maxScaleX: number;
  18298. /**
  18299. * Minimum scale of emitting particles on Y axis.
  18300. */
  18301. minScaleY: number;
  18302. /**
  18303. * Maximum scale of emitting particles on Y axis.
  18304. */
  18305. maxScaleY: number;
  18306. /**
  18307. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18308. */
  18309. color1: Color4;
  18310. /**
  18311. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18312. */
  18313. color2: Color4;
  18314. /**
  18315. * Color the particle will have at the end of its lifetime.
  18316. */
  18317. colorDead: Color4;
  18318. /**
  18319. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18320. */
  18321. emitRate: number;
  18322. /**
  18323. * You can use gravity if you want to give an orientation to your particles.
  18324. */
  18325. gravity: Vector3;
  18326. /**
  18327. * Minimum power of emitting particles.
  18328. */
  18329. minEmitPower: number;
  18330. /**
  18331. * Maximum power of emitting particles.
  18332. */
  18333. maxEmitPower: number;
  18334. /**
  18335. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18336. */
  18337. minAngularSpeed: number;
  18338. /**
  18339. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18340. */
  18341. maxAngularSpeed: number;
  18342. /**
  18343. * Gets or sets the minimal initial rotation in radians.
  18344. */
  18345. minInitialRotation: number;
  18346. /**
  18347. * Gets or sets the maximal initial rotation in radians.
  18348. */
  18349. maxInitialRotation: number;
  18350. /**
  18351. * The particle emitter type defines the emitter used by the particle system.
  18352. * It can be for example box, sphere, or cone...
  18353. */
  18354. particleEmitterType: Nullable<IParticleEmitterType>;
  18355. /**
  18356. * Defines the delay in milliseconds before starting the system (0 by default)
  18357. */
  18358. startDelay: number;
  18359. /**
  18360. * 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
  18361. */
  18362. preWarmCycles: number;
  18363. /**
  18364. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18365. */
  18366. preWarmStepOffset: number;
  18367. /**
  18368. * 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)
  18369. */
  18370. spriteCellChangeSpeed: number;
  18371. /**
  18372. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18373. */
  18374. startSpriteCellID: number;
  18375. /**
  18376. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18377. */
  18378. endSpriteCellID: number;
  18379. /**
  18380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18381. */
  18382. spriteCellWidth: number;
  18383. /**
  18384. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18385. */
  18386. spriteCellHeight: number;
  18387. /**
  18388. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18389. */
  18390. spriteRandomStartCell: boolean;
  18391. /**
  18392. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18393. */
  18394. isAnimationSheetEnabled: boolean;
  18395. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18396. translationPivot: Vector2;
  18397. /**
  18398. * Gets or sets a texture used to add random noise to particle positions
  18399. */
  18400. noiseTexture: Nullable<BaseTexture>;
  18401. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18402. noiseStrength: Vector3;
  18403. /**
  18404. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18405. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18406. */
  18407. billboardMode: number;
  18408. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18409. limitVelocityDamping: number;
  18410. /**
  18411. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18412. */
  18413. beginAnimationOnStart: boolean;
  18414. /**
  18415. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18416. */
  18417. beginAnimationFrom: number;
  18418. /**
  18419. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18420. */
  18421. beginAnimationTo: number;
  18422. /**
  18423. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18424. */
  18425. beginAnimationLoop: boolean;
  18426. /**
  18427. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18428. */
  18429. disposeOnStop: boolean;
  18430. /**
  18431. * Gets the maximum number of particles active at the same time.
  18432. * @returns The max number of active particles.
  18433. */
  18434. getCapacity(): number;
  18435. /**
  18436. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18437. * @returns True if it has been started, otherwise false.
  18438. */
  18439. isStarted(): boolean;
  18440. /**
  18441. * Animates the particle system for this frame.
  18442. */
  18443. animate(): void;
  18444. /**
  18445. * Renders the particle system in its current state.
  18446. * @returns the current number of particles
  18447. */
  18448. render(): number;
  18449. /**
  18450. * Dispose the particle system and frees its associated resources.
  18451. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18452. */
  18453. dispose(disposeTexture?: boolean): void;
  18454. /**
  18455. * Clones the particle system.
  18456. * @param name The name of the cloned object
  18457. * @param newEmitter The new emitter to use
  18458. * @returns the cloned particle system
  18459. */
  18460. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18461. /**
  18462. * Serializes the particle system to a JSON object.
  18463. * @returns the JSON object
  18464. */
  18465. serialize(): any;
  18466. /**
  18467. * Rebuild the particle system
  18468. */
  18469. rebuild(): void;
  18470. /**
  18471. * Starts the particle system and begins to emit
  18472. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18473. */
  18474. start(delay?: number): void;
  18475. /**
  18476. * Stops the particle system.
  18477. */
  18478. stop(): void;
  18479. /**
  18480. * Remove all active particles
  18481. */
  18482. reset(): void;
  18483. /**
  18484. * Is this system ready to be used/rendered
  18485. * @return true if the system is ready
  18486. */
  18487. isReady(): boolean;
  18488. /**
  18489. * Adds a new color gradient
  18490. * @param gradient defines the gradient to use (between 0 and 1)
  18491. * @param color1 defines the color to affect to the specified gradient
  18492. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18493. * @returns the current particle system
  18494. */
  18495. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18496. /**
  18497. * Remove a specific color gradient
  18498. * @param gradient defines the gradient to remove
  18499. * @returns the current particle system
  18500. */
  18501. removeColorGradient(gradient: number): IParticleSystem;
  18502. /**
  18503. * Adds a new size gradient
  18504. * @param gradient defines the gradient to use (between 0 and 1)
  18505. * @param factor defines the size factor to affect to the specified gradient
  18506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18507. * @returns the current particle system
  18508. */
  18509. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18510. /**
  18511. * Remove a specific size gradient
  18512. * @param gradient defines the gradient to remove
  18513. * @returns the current particle system
  18514. */
  18515. removeSizeGradient(gradient: number): IParticleSystem;
  18516. /**
  18517. * Gets the current list of color gradients.
  18518. * You must use addColorGradient and removeColorGradient to udpate this list
  18519. * @returns the list of color gradients
  18520. */
  18521. getColorGradients(): Nullable<Array<ColorGradient>>;
  18522. /**
  18523. * Gets the current list of size gradients.
  18524. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18525. * @returns the list of size gradients
  18526. */
  18527. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18528. /**
  18529. * Gets the current list of angular speed gradients.
  18530. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18531. * @returns the list of angular speed gradients
  18532. */
  18533. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18534. /**
  18535. * Adds a new angular speed gradient
  18536. * @param gradient defines the gradient to use (between 0 and 1)
  18537. * @param factor defines the angular speed to affect to the specified gradient
  18538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18539. * @returns the current particle system
  18540. */
  18541. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18542. /**
  18543. * Remove a specific angular speed gradient
  18544. * @param gradient defines the gradient to remove
  18545. * @returns the current particle system
  18546. */
  18547. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18548. /**
  18549. * Gets the current list of velocity gradients.
  18550. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18551. * @returns the list of velocity gradients
  18552. */
  18553. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18554. /**
  18555. * Adds a new velocity gradient
  18556. * @param gradient defines the gradient to use (between 0 and 1)
  18557. * @param factor defines the velocity to affect to the specified gradient
  18558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18559. * @returns the current particle system
  18560. */
  18561. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18562. /**
  18563. * Remove a specific velocity gradient
  18564. * @param gradient defines the gradient to remove
  18565. * @returns the current particle system
  18566. */
  18567. removeVelocityGradient(gradient: number): IParticleSystem;
  18568. /**
  18569. * Gets the current list of limit velocity gradients.
  18570. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18571. * @returns the list of limit velocity gradients
  18572. */
  18573. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18574. /**
  18575. * Adds a new limit velocity gradient
  18576. * @param gradient defines the gradient to use (between 0 and 1)
  18577. * @param factor defines the limit velocity to affect to the specified gradient
  18578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18579. * @returns the current particle system
  18580. */
  18581. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18582. /**
  18583. * Remove a specific limit velocity gradient
  18584. * @param gradient defines the gradient to remove
  18585. * @returns the current particle system
  18586. */
  18587. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18588. /**
  18589. * Adds a new drag gradient
  18590. * @param gradient defines the gradient to use (between 0 and 1)
  18591. * @param factor defines the drag to affect to the specified gradient
  18592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18593. * @returns the current particle system
  18594. */
  18595. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18596. /**
  18597. * Remove a specific drag gradient
  18598. * @param gradient defines the gradient to remove
  18599. * @returns the current particle system
  18600. */
  18601. removeDragGradient(gradient: number): IParticleSystem;
  18602. /**
  18603. * Gets the current list of drag gradients.
  18604. * You must use addDragGradient and removeDragGradient to udpate this list
  18605. * @returns the list of drag gradients
  18606. */
  18607. getDragGradients(): Nullable<Array<FactorGradient>>;
  18608. /**
  18609. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18610. * @param gradient defines the gradient to use (between 0 and 1)
  18611. * @param factor defines the emit rate to affect to the specified gradient
  18612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18613. * @returns the current particle system
  18614. */
  18615. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18616. /**
  18617. * Remove a specific emit rate gradient
  18618. * @param gradient defines the gradient to remove
  18619. * @returns the current particle system
  18620. */
  18621. removeEmitRateGradient(gradient: number): IParticleSystem;
  18622. /**
  18623. * Gets the current list of emit rate gradients.
  18624. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18625. * @returns the list of emit rate gradients
  18626. */
  18627. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18628. /**
  18629. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18630. * @param gradient defines the gradient to use (between 0 and 1)
  18631. * @param factor defines the start size to affect to the specified gradient
  18632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18633. * @returns the current particle system
  18634. */
  18635. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18636. /**
  18637. * Remove a specific start size gradient
  18638. * @param gradient defines the gradient to remove
  18639. * @returns the current particle system
  18640. */
  18641. removeStartSizeGradient(gradient: number): IParticleSystem;
  18642. /**
  18643. * Gets the current list of start size gradients.
  18644. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18645. * @returns the list of start size gradients
  18646. */
  18647. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18648. /**
  18649. * Adds a new life time gradient
  18650. * @param gradient defines the gradient to use (between 0 and 1)
  18651. * @param factor defines the life time factor to affect to the specified gradient
  18652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18653. * @returns the current particle system
  18654. */
  18655. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18656. /**
  18657. * Remove a specific life time gradient
  18658. * @param gradient defines the gradient to remove
  18659. * @returns the current particle system
  18660. */
  18661. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18662. /**
  18663. * Gets the current list of life time gradients.
  18664. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18665. * @returns the list of life time gradients
  18666. */
  18667. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18668. /**
  18669. * Gets the current list of color gradients.
  18670. * You must use addColorGradient and removeColorGradient to udpate this list
  18671. * @returns the list of color gradients
  18672. */
  18673. getColorGradients(): Nullable<Array<ColorGradient>>;
  18674. /**
  18675. * Adds a new ramp gradient used to remap particle colors
  18676. * @param gradient defines the gradient to use (between 0 and 1)
  18677. * @param color defines the color to affect to the specified gradient
  18678. * @returns the current particle system
  18679. */
  18680. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18681. /**
  18682. * Gets the current list of ramp gradients.
  18683. * You must use addRampGradient and removeRampGradient to udpate this list
  18684. * @returns the list of ramp gradients
  18685. */
  18686. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18687. /** Gets or sets a boolean indicating that ramp gradients must be used
  18688. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18689. */
  18690. useRampGradients: boolean;
  18691. /**
  18692. * Adds a new color remap gradient
  18693. * @param gradient defines the gradient to use (between 0 and 1)
  18694. * @param min defines the color remap minimal range
  18695. * @param max defines the color remap maximal range
  18696. * @returns the current particle system
  18697. */
  18698. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18699. /**
  18700. * Gets the current list of color remap gradients.
  18701. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18702. * @returns the list of color remap gradients
  18703. */
  18704. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18705. /**
  18706. * Adds a new alpha remap gradient
  18707. * @param gradient defines the gradient to use (between 0 and 1)
  18708. * @param min defines the alpha remap minimal range
  18709. * @param max defines the alpha remap maximal range
  18710. * @returns the current particle system
  18711. */
  18712. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18713. /**
  18714. * Gets the current list of alpha remap gradients.
  18715. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18716. * @returns the list of alpha remap gradients
  18717. */
  18718. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18719. /**
  18720. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18721. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18722. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18723. * @returns the emitter
  18724. */
  18725. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18726. /**
  18727. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18728. * @param radius The radius of the hemisphere to emit from
  18729. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18730. * @returns the emitter
  18731. */
  18732. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18733. /**
  18734. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18735. * @param radius The radius of the sphere to emit from
  18736. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18737. * @returns the emitter
  18738. */
  18739. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18740. /**
  18741. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18742. * @param radius The radius of the sphere to emit from
  18743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18745. * @returns the emitter
  18746. */
  18747. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18748. /**
  18749. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18750. * @param radius The radius of the emission cylinder
  18751. * @param height The height of the emission cylinder
  18752. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18753. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18754. * @returns the emitter
  18755. */
  18756. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18757. /**
  18758. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18759. * @param radius The radius of the cylinder to emit from
  18760. * @param height The height of the emission cylinder
  18761. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18762. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18763. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18764. * @returns the emitter
  18765. */
  18766. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18767. /**
  18768. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18769. * @param radius The radius of the cone to emit from
  18770. * @param angle The base angle of the cone
  18771. * @returns the emitter
  18772. */
  18773. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18774. /**
  18775. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18776. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18777. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18778. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18779. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18780. * @returns the emitter
  18781. */
  18782. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18783. /**
  18784. * Get hosting scene
  18785. * @returns the scene
  18786. */
  18787. getScene(): Scene;
  18788. }
  18789. }
  18790. declare module BABYLON {
  18791. /**
  18792. * Creates an instance based on a source mesh.
  18793. */
  18794. export class InstancedMesh extends AbstractMesh {
  18795. private _sourceMesh;
  18796. private _currentLOD;
  18797. /** @hidden */
  18798. _indexInSourceMeshInstanceArray: number;
  18799. constructor(name: string, source: Mesh);
  18800. /**
  18801. * Returns the string "InstancedMesh".
  18802. */
  18803. getClassName(): string;
  18804. /** Gets the list of lights affecting that mesh */
  18805. readonly lightSources: Light[];
  18806. _resyncLightSources(): void;
  18807. _resyncLighSource(light: Light): void;
  18808. _removeLightSource(light: Light, dispose: boolean): void;
  18809. /**
  18810. * If the source mesh receives shadows
  18811. */
  18812. readonly receiveShadows: boolean;
  18813. /**
  18814. * The material of the source mesh
  18815. */
  18816. readonly material: Nullable<Material>;
  18817. /**
  18818. * Visibility of the source mesh
  18819. */
  18820. readonly visibility: number;
  18821. /**
  18822. * Skeleton of the source mesh
  18823. */
  18824. readonly skeleton: Nullable<Skeleton>;
  18825. /**
  18826. * Rendering ground id of the source mesh
  18827. */
  18828. renderingGroupId: number;
  18829. /**
  18830. * Returns the total number of vertices (integer).
  18831. */
  18832. getTotalVertices(): number;
  18833. /**
  18834. * Returns a positive integer : the total number of indices in this mesh geometry.
  18835. * @returns the numner of indices or zero if the mesh has no geometry.
  18836. */
  18837. getTotalIndices(): number;
  18838. /**
  18839. * The source mesh of the instance
  18840. */
  18841. readonly sourceMesh: Mesh;
  18842. /**
  18843. * Is this node ready to be used/rendered
  18844. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18845. * @return {boolean} is it ready
  18846. */
  18847. isReady(completeCheck?: boolean): boolean;
  18848. /**
  18849. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18850. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18851. * @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.
  18852. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18853. */
  18854. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18855. /**
  18856. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18857. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18858. * The `data` are either a numeric array either a Float32Array.
  18859. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18860. * 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).
  18861. * Note that a new underlying VertexBuffer object is created each call.
  18862. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18863. *
  18864. * Possible `kind` values :
  18865. * - VertexBuffer.PositionKind
  18866. * - VertexBuffer.UVKind
  18867. * - VertexBuffer.UV2Kind
  18868. * - VertexBuffer.UV3Kind
  18869. * - VertexBuffer.UV4Kind
  18870. * - VertexBuffer.UV5Kind
  18871. * - VertexBuffer.UV6Kind
  18872. * - VertexBuffer.ColorKind
  18873. * - VertexBuffer.MatricesIndicesKind
  18874. * - VertexBuffer.MatricesIndicesExtraKind
  18875. * - VertexBuffer.MatricesWeightsKind
  18876. * - VertexBuffer.MatricesWeightsExtraKind
  18877. *
  18878. * Returns the Mesh.
  18879. */
  18880. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18881. /**
  18882. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18883. * If the mesh has no geometry, it is simply returned as it is.
  18884. * The `data` are either a numeric array either a Float32Array.
  18885. * No new underlying VertexBuffer object is created.
  18886. * 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.
  18887. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18888. *
  18889. * Possible `kind` values :
  18890. * - VertexBuffer.PositionKind
  18891. * - VertexBuffer.UVKind
  18892. * - VertexBuffer.UV2Kind
  18893. * - VertexBuffer.UV3Kind
  18894. * - VertexBuffer.UV4Kind
  18895. * - VertexBuffer.UV5Kind
  18896. * - VertexBuffer.UV6Kind
  18897. * - VertexBuffer.ColorKind
  18898. * - VertexBuffer.MatricesIndicesKind
  18899. * - VertexBuffer.MatricesIndicesExtraKind
  18900. * - VertexBuffer.MatricesWeightsKind
  18901. * - VertexBuffer.MatricesWeightsExtraKind
  18902. *
  18903. * Returns the Mesh.
  18904. */
  18905. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18906. /**
  18907. * Sets the mesh indices.
  18908. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18909. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18910. * This method creates a new index buffer each call.
  18911. * Returns the Mesh.
  18912. */
  18913. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18914. /**
  18915. * Boolean : True if the mesh owns the requested kind of data.
  18916. */
  18917. isVerticesDataPresent(kind: string): boolean;
  18918. /**
  18919. * Returns an array of indices (IndicesArray).
  18920. */
  18921. getIndices(): Nullable<IndicesArray>;
  18922. readonly _positions: Nullable<Vector3[]>;
  18923. /**
  18924. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18925. * This means the mesh underlying bounding box and sphere are recomputed.
  18926. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18927. * @returns the current mesh
  18928. */
  18929. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18930. /** @hidden */
  18931. _preActivate(): InstancedMesh;
  18932. /** @hidden */
  18933. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18934. /** @hidden */
  18935. _postActivate(): void;
  18936. getWorldMatrix(): Matrix;
  18937. readonly isAnInstance: boolean;
  18938. /**
  18939. * Returns the current associated LOD AbstractMesh.
  18940. */
  18941. getLOD(camera: Camera): AbstractMesh;
  18942. /** @hidden */
  18943. _syncSubMeshes(): InstancedMesh;
  18944. /** @hidden */
  18945. _generatePointsArray(): boolean;
  18946. /**
  18947. * Creates a new InstancedMesh from the current mesh.
  18948. * - name (string) : the cloned mesh name
  18949. * - newParent (optional Node) : the optional Node to parent the clone to.
  18950. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18951. *
  18952. * Returns the clone.
  18953. */
  18954. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18955. /**
  18956. * Disposes the InstancedMesh.
  18957. * Returns nothing.
  18958. */
  18959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18960. }
  18961. }
  18962. declare module BABYLON {
  18963. /**
  18964. * Defines the options associated with the creation of a shader material.
  18965. */
  18966. export interface IShaderMaterialOptions {
  18967. /**
  18968. * Does the material work in alpha blend mode
  18969. */
  18970. needAlphaBlending: boolean;
  18971. /**
  18972. * Does the material work in alpha test mode
  18973. */
  18974. needAlphaTesting: boolean;
  18975. /**
  18976. * The list of attribute names used in the shader
  18977. */
  18978. attributes: string[];
  18979. /**
  18980. * The list of unifrom names used in the shader
  18981. */
  18982. uniforms: string[];
  18983. /**
  18984. * The list of UBO names used in the shader
  18985. */
  18986. uniformBuffers: string[];
  18987. /**
  18988. * The list of sampler names used in the shader
  18989. */
  18990. samplers: string[];
  18991. /**
  18992. * The list of defines used in the shader
  18993. */
  18994. defines: string[];
  18995. }
  18996. /**
  18997. * 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.
  18998. *
  18999. * This returned material effects how the mesh will look based on the code in the shaders.
  19000. *
  19001. * @see http://doc.babylonjs.com/how_to/shader_material
  19002. */
  19003. export class ShaderMaterial extends Material {
  19004. private _shaderPath;
  19005. private _options;
  19006. private _textures;
  19007. private _textureArrays;
  19008. private _floats;
  19009. private _ints;
  19010. private _floatsArrays;
  19011. private _colors3;
  19012. private _colors3Arrays;
  19013. private _colors4;
  19014. private _colors4Arrays;
  19015. private _vectors2;
  19016. private _vectors3;
  19017. private _vectors4;
  19018. private _matrices;
  19019. private _matrices3x3;
  19020. private _matrices2x2;
  19021. private _vectors2Arrays;
  19022. private _vectors3Arrays;
  19023. private _vectors4Arrays;
  19024. private _cachedWorldViewMatrix;
  19025. private _cachedWorldViewProjectionMatrix;
  19026. private _renderId;
  19027. /**
  19028. * Instantiate a new shader material.
  19029. * 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.
  19030. * This returned material effects how the mesh will look based on the code in the shaders.
  19031. * @see http://doc.babylonjs.com/how_to/shader_material
  19032. * @param name Define the name of the material in the scene
  19033. * @param scene Define the scene the material belongs to
  19034. * @param shaderPath Defines the route to the shader code in one of three ways:
  19035. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19036. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19037. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19038. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19039. * @param options Define the options used to create the shader
  19040. */
  19041. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19042. /**
  19043. * Gets the options used to compile the shader.
  19044. * They can be modified to trigger a new compilation
  19045. */
  19046. readonly options: IShaderMaterialOptions;
  19047. /**
  19048. * Gets the current class name of the material e.g. "ShaderMaterial"
  19049. * Mainly use in serialization.
  19050. * @returns the class name
  19051. */
  19052. getClassName(): string;
  19053. /**
  19054. * Specifies if the material will require alpha blending
  19055. * @returns a boolean specifying if alpha blending is needed
  19056. */
  19057. needAlphaBlending(): boolean;
  19058. /**
  19059. * Specifies if this material should be rendered in alpha test mode
  19060. * @returns a boolean specifying if an alpha test is needed.
  19061. */
  19062. needAlphaTesting(): boolean;
  19063. private _checkUniform;
  19064. /**
  19065. * Set a texture in the shader.
  19066. * @param name Define the name of the uniform samplers as defined in the shader
  19067. * @param texture Define the texture to bind to this sampler
  19068. * @return the material itself allowing "fluent" like uniform updates
  19069. */
  19070. setTexture(name: string, texture: Texture): ShaderMaterial;
  19071. /**
  19072. * Set a texture array in the shader.
  19073. * @param name Define the name of the uniform sampler array as defined in the shader
  19074. * @param textures Define the list of textures to bind to this sampler
  19075. * @return the material itself allowing "fluent" like uniform updates
  19076. */
  19077. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19078. /**
  19079. * Set a float in the shader.
  19080. * @param name Define the name of the uniform as defined in the shader
  19081. * @param value Define the value to give to the uniform
  19082. * @return the material itself allowing "fluent" like uniform updates
  19083. */
  19084. setFloat(name: string, value: number): ShaderMaterial;
  19085. /**
  19086. * Set a int in the shader.
  19087. * @param name Define the name of the uniform as defined in the shader
  19088. * @param value Define the value to give to the uniform
  19089. * @return the material itself allowing "fluent" like uniform updates
  19090. */
  19091. setInt(name: string, value: number): ShaderMaterial;
  19092. /**
  19093. * Set an array of floats in the shader.
  19094. * @param name Define the name of the uniform as defined in the shader
  19095. * @param value Define the value to give to the uniform
  19096. * @return the material itself allowing "fluent" like uniform updates
  19097. */
  19098. setFloats(name: string, value: number[]): ShaderMaterial;
  19099. /**
  19100. * Set a vec3 in the shader from a Color3.
  19101. * @param name Define the name of the uniform as defined in the shader
  19102. * @param value Define the value to give to the uniform
  19103. * @return the material itself allowing "fluent" like uniform updates
  19104. */
  19105. setColor3(name: string, value: Color3): ShaderMaterial;
  19106. /**
  19107. * Set a vec3 array in the shader from a Color3 array.
  19108. * @param name Define the name of the uniform as defined in the shader
  19109. * @param value Define the value to give to the uniform
  19110. * @return the material itself allowing "fluent" like uniform updates
  19111. */
  19112. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19113. /**
  19114. * Set a vec4 in the shader from a Color4.
  19115. * @param name Define the name of the uniform as defined in the shader
  19116. * @param value Define the value to give to the uniform
  19117. * @return the material itself allowing "fluent" like uniform updates
  19118. */
  19119. setColor4(name: string, value: Color4): ShaderMaterial;
  19120. /**
  19121. * Set a vec4 array in the shader from a Color4 array.
  19122. * @param name Define the name of the uniform as defined in the shader
  19123. * @param value Define the value to give to the uniform
  19124. * @return the material itself allowing "fluent" like uniform updates
  19125. */
  19126. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19127. /**
  19128. * Set a vec2 in the shader from a Vector2.
  19129. * @param name Define the name of the uniform as defined in the shader
  19130. * @param value Define the value to give to the uniform
  19131. * @return the material itself allowing "fluent" like uniform updates
  19132. */
  19133. setVector2(name: string, value: Vector2): ShaderMaterial;
  19134. /**
  19135. * Set a vec3 in the shader from a Vector3.
  19136. * @param name Define the name of the uniform as defined in the shader
  19137. * @param value Define the value to give to the uniform
  19138. * @return the material itself allowing "fluent" like uniform updates
  19139. */
  19140. setVector3(name: string, value: Vector3): ShaderMaterial;
  19141. /**
  19142. * Set a vec4 in the shader from a Vector4.
  19143. * @param name Define the name of the uniform as defined in the shader
  19144. * @param value Define the value to give to the uniform
  19145. * @return the material itself allowing "fluent" like uniform updates
  19146. */
  19147. setVector4(name: string, value: Vector4): ShaderMaterial;
  19148. /**
  19149. * Set a mat4 in the shader from a Matrix.
  19150. * @param name Define the name of the uniform as defined in the shader
  19151. * @param value Define the value to give to the uniform
  19152. * @return the material itself allowing "fluent" like uniform updates
  19153. */
  19154. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19155. /**
  19156. * Set a mat3 in the shader from a Float32Array.
  19157. * @param name Define the name of the uniform as defined in the shader
  19158. * @param value Define the value to give to the uniform
  19159. * @return the material itself allowing "fluent" like uniform updates
  19160. */
  19161. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19162. /**
  19163. * Set a mat2 in the shader from a Float32Array.
  19164. * @param name Define the name of the uniform as defined in the shader
  19165. * @param value Define the value to give to the uniform
  19166. * @return the material itself allowing "fluent" like uniform updates
  19167. */
  19168. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19169. /**
  19170. * Set a vec2 array in the shader from a number array.
  19171. * @param name Define the name of the uniform as defined in the shader
  19172. * @param value Define the value to give to the uniform
  19173. * @return the material itself allowing "fluent" like uniform updates
  19174. */
  19175. setArray2(name: string, value: number[]): ShaderMaterial;
  19176. /**
  19177. * Set a vec3 array in the shader from a number array.
  19178. * @param name Define the name of the uniform as defined in the shader
  19179. * @param value Define the value to give to the uniform
  19180. * @return the material itself allowing "fluent" like uniform updates
  19181. */
  19182. setArray3(name: string, value: number[]): ShaderMaterial;
  19183. /**
  19184. * Set a vec4 array in the shader from a number array.
  19185. * @param name Define the name of the uniform as defined in the shader
  19186. * @param value Define the value to give to the uniform
  19187. * @return the material itself allowing "fluent" like uniform updates
  19188. */
  19189. setArray4(name: string, value: number[]): ShaderMaterial;
  19190. private _checkCache;
  19191. /**
  19192. * Specifies that the submesh is ready to be used
  19193. * @param mesh defines the mesh to check
  19194. * @param subMesh defines which submesh to check
  19195. * @param useInstances specifies that instances should be used
  19196. * @returns a boolean indicating that the submesh is ready or not
  19197. */
  19198. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19199. /**
  19200. * Checks if the material is ready to render the requested mesh
  19201. * @param mesh Define the mesh to render
  19202. * @param useInstances Define whether or not the material is used with instances
  19203. * @returns true if ready, otherwise false
  19204. */
  19205. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19206. /**
  19207. * Binds the world matrix to the material
  19208. * @param world defines the world transformation matrix
  19209. */
  19210. bindOnlyWorldMatrix(world: Matrix): void;
  19211. /**
  19212. * Binds the material to the mesh
  19213. * @param world defines the world transformation matrix
  19214. * @param mesh defines the mesh to bind the material to
  19215. */
  19216. bind(world: Matrix, mesh?: Mesh): void;
  19217. /**
  19218. * Gets the active textures from the material
  19219. * @returns an array of textures
  19220. */
  19221. getActiveTextures(): BaseTexture[];
  19222. /**
  19223. * Specifies if the material uses a texture
  19224. * @param texture defines the texture to check against the material
  19225. * @returns a boolean specifying if the material uses the texture
  19226. */
  19227. hasTexture(texture: BaseTexture): boolean;
  19228. /**
  19229. * Makes a duplicate of the material, and gives it a new name
  19230. * @param name defines the new name for the duplicated material
  19231. * @returns the cloned material
  19232. */
  19233. clone(name: string): ShaderMaterial;
  19234. /**
  19235. * Disposes the material
  19236. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19237. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19238. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19239. */
  19240. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19241. /**
  19242. * Serializes this material in a JSON representation
  19243. * @returns the serialized material object
  19244. */
  19245. serialize(): any;
  19246. /**
  19247. * Creates a shader material from parsed shader material data
  19248. * @param source defines the JSON represnetation of the material
  19249. * @param scene defines the hosting scene
  19250. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19251. * @returns a new material
  19252. */
  19253. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19254. }
  19255. }
  19256. declare module BABYLON {
  19257. /** @hidden */
  19258. export var colorPixelShader: {
  19259. name: string;
  19260. shader: string;
  19261. };
  19262. }
  19263. declare module BABYLON {
  19264. /** @hidden */
  19265. export var colorVertexShader: {
  19266. name: string;
  19267. shader: string;
  19268. };
  19269. }
  19270. declare module BABYLON {
  19271. /**
  19272. * Line mesh
  19273. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19274. */
  19275. export class LinesMesh extends Mesh {
  19276. /**
  19277. * If vertex color should be applied to the mesh
  19278. */
  19279. readonly useVertexColor?: boolean | undefined;
  19280. /**
  19281. * If vertex alpha should be applied to the mesh
  19282. */
  19283. readonly useVertexAlpha?: boolean | undefined;
  19284. /**
  19285. * Color of the line (Default: White)
  19286. */
  19287. color: Color3;
  19288. /**
  19289. * Alpha of the line (Default: 1)
  19290. */
  19291. alpha: number;
  19292. /**
  19293. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19294. * This margin is expressed in world space coordinates, so its value may vary.
  19295. * Default value is 0.1
  19296. */
  19297. intersectionThreshold: number;
  19298. private _colorShader;
  19299. private color4;
  19300. /**
  19301. * Creates a new LinesMesh
  19302. * @param name defines the name
  19303. * @param scene defines the hosting scene
  19304. * @param parent defines the parent mesh if any
  19305. * @param source defines the optional source LinesMesh used to clone data from
  19306. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19307. * When false, achieved by calling a clone(), also passing False.
  19308. * This will make creation of children, recursive.
  19309. * @param useVertexColor defines if this LinesMesh supports vertex color
  19310. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19311. */
  19312. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19313. /**
  19314. * If vertex color should be applied to the mesh
  19315. */
  19316. useVertexColor?: boolean | undefined,
  19317. /**
  19318. * If vertex alpha should be applied to the mesh
  19319. */
  19320. useVertexAlpha?: boolean | undefined);
  19321. private _addClipPlaneDefine;
  19322. private _removeClipPlaneDefine;
  19323. isReady(): boolean;
  19324. /**
  19325. * Returns the string "LineMesh"
  19326. */
  19327. getClassName(): string;
  19328. /**
  19329. * @hidden
  19330. */
  19331. /**
  19332. * @hidden
  19333. */
  19334. material: Material;
  19335. /**
  19336. * @hidden
  19337. */
  19338. readonly checkCollisions: boolean;
  19339. /** @hidden */
  19340. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19341. /** @hidden */
  19342. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19343. /**
  19344. * Disposes of the line mesh
  19345. * @param doNotRecurse If children should be disposed
  19346. */
  19347. dispose(doNotRecurse?: boolean): void;
  19348. /**
  19349. * Returns a new LineMesh object cloned from the current one.
  19350. */
  19351. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19352. /**
  19353. * Creates a new InstancedLinesMesh object from the mesh model.
  19354. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19355. * @param name defines the name of the new instance
  19356. * @returns a new InstancedLinesMesh
  19357. */
  19358. createInstance(name: string): InstancedLinesMesh;
  19359. }
  19360. /**
  19361. * Creates an instance based on a source LinesMesh
  19362. */
  19363. export class InstancedLinesMesh extends InstancedMesh {
  19364. /**
  19365. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19366. * This margin is expressed in world space coordinates, so its value may vary.
  19367. * Initilized with the intersectionThreshold value of the source LinesMesh
  19368. */
  19369. intersectionThreshold: number;
  19370. constructor(name: string, source: LinesMesh);
  19371. /**
  19372. * Returns the string "InstancedLinesMesh".
  19373. */
  19374. getClassName(): string;
  19375. }
  19376. }
  19377. declare module BABYLON {
  19378. /** @hidden */
  19379. export var linePixelShader: {
  19380. name: string;
  19381. shader: string;
  19382. };
  19383. }
  19384. declare module BABYLON {
  19385. /** @hidden */
  19386. export var lineVertexShader: {
  19387. name: string;
  19388. shader: string;
  19389. };
  19390. }
  19391. declare module BABYLON {
  19392. interface AbstractMesh {
  19393. /**
  19394. * Gets the edgesRenderer associated with the mesh
  19395. */
  19396. edgesRenderer: Nullable<EdgesRenderer>;
  19397. }
  19398. interface LinesMesh {
  19399. /**
  19400. * Enables the edge rendering mode on the mesh.
  19401. * This mode makes the mesh edges visible
  19402. * @param epsilon defines the maximal distance between two angles to detect a face
  19403. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19404. * @returns the currentAbstractMesh
  19405. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19406. */
  19407. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19408. }
  19409. interface InstancedLinesMesh {
  19410. /**
  19411. * Enables the edge rendering mode on the mesh.
  19412. * This mode makes the mesh edges visible
  19413. * @param epsilon defines the maximal distance between two angles to detect a face
  19414. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19415. * @returns the current InstancedLinesMesh
  19416. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19417. */
  19418. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19419. }
  19420. /**
  19421. * Defines the minimum contract an Edges renderer should follow.
  19422. */
  19423. export interface IEdgesRenderer extends IDisposable {
  19424. /**
  19425. * Gets or sets a boolean indicating if the edgesRenderer is active
  19426. */
  19427. isEnabled: boolean;
  19428. /**
  19429. * Renders the edges of the attached mesh,
  19430. */
  19431. render(): void;
  19432. /**
  19433. * Checks wether or not the edges renderer is ready to render.
  19434. * @return true if ready, otherwise false.
  19435. */
  19436. isReady(): boolean;
  19437. }
  19438. /**
  19439. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19440. */
  19441. export class EdgesRenderer implements IEdgesRenderer {
  19442. /**
  19443. * Define the size of the edges with an orthographic camera
  19444. */
  19445. edgesWidthScalerForOrthographic: number;
  19446. /**
  19447. * Define the size of the edges with a perspective camera
  19448. */
  19449. edgesWidthScalerForPerspective: number;
  19450. protected _source: AbstractMesh;
  19451. protected _linesPositions: number[];
  19452. protected _linesNormals: number[];
  19453. protected _linesIndices: number[];
  19454. protected _epsilon: number;
  19455. protected _indicesCount: number;
  19456. protected _lineShader: ShaderMaterial;
  19457. protected _ib: DataBuffer;
  19458. protected _buffers: {
  19459. [key: string]: Nullable<VertexBuffer>;
  19460. };
  19461. protected _checkVerticesInsteadOfIndices: boolean;
  19462. private _meshRebuildObserver;
  19463. private _meshDisposeObserver;
  19464. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19465. isEnabled: boolean;
  19466. /**
  19467. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19468. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19469. * @param source Mesh used to create edges
  19470. * @param epsilon sum of angles in adjacency to check for edge
  19471. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19472. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19473. */
  19474. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19475. protected _prepareRessources(): void;
  19476. /** @hidden */
  19477. _rebuild(): void;
  19478. /**
  19479. * Releases the required resources for the edges renderer
  19480. */
  19481. dispose(): void;
  19482. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19483. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19484. /**
  19485. * Checks if the pair of p0 and p1 is en edge
  19486. * @param faceIndex
  19487. * @param edge
  19488. * @param faceNormals
  19489. * @param p0
  19490. * @param p1
  19491. * @private
  19492. */
  19493. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19494. /**
  19495. * push line into the position, normal and index buffer
  19496. * @protected
  19497. */
  19498. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19499. /**
  19500. * Generates lines edges from adjacencjes
  19501. * @private
  19502. */
  19503. _generateEdgesLines(): void;
  19504. /**
  19505. * Checks wether or not the edges renderer is ready to render.
  19506. * @return true if ready, otherwise false.
  19507. */
  19508. isReady(): boolean;
  19509. /**
  19510. * Renders the edges of the attached mesh,
  19511. */
  19512. render(): void;
  19513. }
  19514. /**
  19515. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19516. */
  19517. export class LineEdgesRenderer extends EdgesRenderer {
  19518. /**
  19519. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19520. * @param source LineMesh used to generate edges
  19521. * @param epsilon not important (specified angle for edge detection)
  19522. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19523. */
  19524. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19525. /**
  19526. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19527. */
  19528. _generateEdgesLines(): void;
  19529. }
  19530. }
  19531. declare module BABYLON {
  19532. /**
  19533. * This represents the object necessary to create a rendering group.
  19534. * This is exclusively used and created by the rendering manager.
  19535. * To modify the behavior, you use the available helpers in your scene or meshes.
  19536. * @hidden
  19537. */
  19538. export class RenderingGroup {
  19539. index: number;
  19540. private static _zeroVector;
  19541. private _scene;
  19542. private _opaqueSubMeshes;
  19543. private _transparentSubMeshes;
  19544. private _alphaTestSubMeshes;
  19545. private _depthOnlySubMeshes;
  19546. private _particleSystems;
  19547. private _spriteManagers;
  19548. private _opaqueSortCompareFn;
  19549. private _alphaTestSortCompareFn;
  19550. private _transparentSortCompareFn;
  19551. private _renderOpaque;
  19552. private _renderAlphaTest;
  19553. private _renderTransparent;
  19554. /** @hidden */
  19555. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19556. onBeforeTransparentRendering: () => void;
  19557. /**
  19558. * Set the opaque sort comparison function.
  19559. * If null the sub meshes will be render in the order they were created
  19560. */
  19561. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19562. /**
  19563. * Set the alpha test sort comparison function.
  19564. * If null the sub meshes will be render in the order they were created
  19565. */
  19566. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19567. /**
  19568. * Set the transparent sort comparison function.
  19569. * If null the sub meshes will be render in the order they were created
  19570. */
  19571. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19572. /**
  19573. * Creates a new rendering group.
  19574. * @param index The rendering group index
  19575. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19576. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19577. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19578. */
  19579. 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>);
  19580. /**
  19581. * Render all the sub meshes contained in the group.
  19582. * @param customRenderFunction Used to override the default render behaviour of the group.
  19583. * @returns true if rendered some submeshes.
  19584. */
  19585. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19586. /**
  19587. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19588. * @param subMeshes The submeshes to render
  19589. */
  19590. private renderOpaqueSorted;
  19591. /**
  19592. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19593. * @param subMeshes The submeshes to render
  19594. */
  19595. private renderAlphaTestSorted;
  19596. /**
  19597. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19598. * @param subMeshes The submeshes to render
  19599. */
  19600. private renderTransparentSorted;
  19601. /**
  19602. * Renders the submeshes in a specified order.
  19603. * @param subMeshes The submeshes to sort before render
  19604. * @param sortCompareFn The comparison function use to sort
  19605. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19606. * @param transparent Specifies to activate blending if true
  19607. */
  19608. private static renderSorted;
  19609. /**
  19610. * Renders the submeshes in the order they were dispatched (no sort applied).
  19611. * @param subMeshes The submeshes to render
  19612. */
  19613. private static renderUnsorted;
  19614. /**
  19615. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19616. * are rendered back to front if in the same alpha index.
  19617. *
  19618. * @param a The first submesh
  19619. * @param b The second submesh
  19620. * @returns The result of the comparison
  19621. */
  19622. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19623. /**
  19624. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19625. * are rendered back to front.
  19626. *
  19627. * @param a The first submesh
  19628. * @param b The second submesh
  19629. * @returns The result of the comparison
  19630. */
  19631. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19632. /**
  19633. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19634. * are rendered front to back (prevent overdraw).
  19635. *
  19636. * @param a The first submesh
  19637. * @param b The second submesh
  19638. * @returns The result of the comparison
  19639. */
  19640. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19641. /**
  19642. * Resets the different lists of submeshes to prepare a new frame.
  19643. */
  19644. prepare(): void;
  19645. dispose(): void;
  19646. /**
  19647. * Inserts the submesh in its correct queue depending on its material.
  19648. * @param subMesh The submesh to dispatch
  19649. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19650. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19651. */
  19652. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19653. dispatchSprites(spriteManager: ISpriteManager): void;
  19654. dispatchParticles(particleSystem: IParticleSystem): void;
  19655. private _renderParticles;
  19656. private _renderSprites;
  19657. }
  19658. }
  19659. declare module BABYLON {
  19660. /**
  19661. * Interface describing the different options available in the rendering manager
  19662. * regarding Auto Clear between groups.
  19663. */
  19664. export interface IRenderingManagerAutoClearSetup {
  19665. /**
  19666. * Defines whether or not autoclear is enable.
  19667. */
  19668. autoClear: boolean;
  19669. /**
  19670. * Defines whether or not to autoclear the depth buffer.
  19671. */
  19672. depth: boolean;
  19673. /**
  19674. * Defines whether or not to autoclear the stencil buffer.
  19675. */
  19676. stencil: boolean;
  19677. }
  19678. /**
  19679. * This class is used by the onRenderingGroupObservable
  19680. */
  19681. export class RenderingGroupInfo {
  19682. /**
  19683. * The Scene that being rendered
  19684. */
  19685. scene: Scene;
  19686. /**
  19687. * The camera currently used for the rendering pass
  19688. */
  19689. camera: Nullable<Camera>;
  19690. /**
  19691. * The ID of the renderingGroup being processed
  19692. */
  19693. renderingGroupId: number;
  19694. }
  19695. /**
  19696. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19697. * It is enable to manage the different groups as well as the different necessary sort functions.
  19698. * This should not be used directly aside of the few static configurations
  19699. */
  19700. export class RenderingManager {
  19701. /**
  19702. * The max id used for rendering groups (not included)
  19703. */
  19704. static MAX_RENDERINGGROUPS: number;
  19705. /**
  19706. * The min id used for rendering groups (included)
  19707. */
  19708. static MIN_RENDERINGGROUPS: number;
  19709. /**
  19710. * Used to globally prevent autoclearing scenes.
  19711. */
  19712. static AUTOCLEAR: boolean;
  19713. /**
  19714. * @hidden
  19715. */
  19716. _useSceneAutoClearSetup: boolean;
  19717. private _scene;
  19718. private _renderingGroups;
  19719. private _depthStencilBufferAlreadyCleaned;
  19720. private _autoClearDepthStencil;
  19721. private _customOpaqueSortCompareFn;
  19722. private _customAlphaTestSortCompareFn;
  19723. private _customTransparentSortCompareFn;
  19724. private _renderingGroupInfo;
  19725. /**
  19726. * Instantiates a new rendering group for a particular scene
  19727. * @param scene Defines the scene the groups belongs to
  19728. */
  19729. constructor(scene: Scene);
  19730. private _clearDepthStencilBuffer;
  19731. /**
  19732. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19733. * @hidden
  19734. */
  19735. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19736. /**
  19737. * Resets the different information of the group to prepare a new frame
  19738. * @hidden
  19739. */
  19740. reset(): void;
  19741. /**
  19742. * Dispose and release the group and its associated resources.
  19743. * @hidden
  19744. */
  19745. dispose(): void;
  19746. /**
  19747. * Clear the info related to rendering groups preventing retention points during dispose.
  19748. */
  19749. freeRenderingGroups(): void;
  19750. private _prepareRenderingGroup;
  19751. /**
  19752. * Add a sprite manager to the rendering manager in order to render it this frame.
  19753. * @param spriteManager Define the sprite manager to render
  19754. */
  19755. dispatchSprites(spriteManager: ISpriteManager): void;
  19756. /**
  19757. * Add a particle system to the rendering manager in order to render it this frame.
  19758. * @param particleSystem Define the particle system to render
  19759. */
  19760. dispatchParticles(particleSystem: IParticleSystem): void;
  19761. /**
  19762. * Add a submesh to the manager in order to render it this frame
  19763. * @param subMesh The submesh to dispatch
  19764. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19765. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19766. */
  19767. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19768. /**
  19769. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19770. * This allowed control for front to back rendering or reversly depending of the special needs.
  19771. *
  19772. * @param renderingGroupId The rendering group id corresponding to its index
  19773. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19774. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19775. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19776. */
  19777. 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;
  19778. /**
  19779. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19780. *
  19781. * @param renderingGroupId The rendering group id corresponding to its index
  19782. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19783. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19784. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19785. */
  19786. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19787. /**
  19788. * Gets the current auto clear configuration for one rendering group of the rendering
  19789. * manager.
  19790. * @param index the rendering group index to get the information for
  19791. * @returns The auto clear setup for the requested rendering group
  19792. */
  19793. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19794. }
  19795. }
  19796. declare module BABYLON {
  19797. /**
  19798. * This Helps creating a texture that will be created from a camera in your scene.
  19799. * It is basically a dynamic texture that could be used to create special effects for instance.
  19800. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19801. */
  19802. export class RenderTargetTexture extends Texture {
  19803. isCube: boolean;
  19804. /**
  19805. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19806. */
  19807. static readonly REFRESHRATE_RENDER_ONCE: number;
  19808. /**
  19809. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19810. */
  19811. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19812. /**
  19813. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19814. * the central point of your effect and can save a lot of performances.
  19815. */
  19816. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19817. /**
  19818. * Use this predicate to dynamically define the list of mesh you want to render.
  19819. * If set, the renderList property will be overwritten.
  19820. */
  19821. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19822. private _renderList;
  19823. /**
  19824. * Use this list to define the list of mesh you want to render.
  19825. */
  19826. renderList: Nullable<Array<AbstractMesh>>;
  19827. private _hookArray;
  19828. /**
  19829. * Define if particles should be rendered in your texture.
  19830. */
  19831. renderParticles: boolean;
  19832. /**
  19833. * Define if sprites should be rendered in your texture.
  19834. */
  19835. renderSprites: boolean;
  19836. /**
  19837. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19838. */
  19839. coordinatesMode: number;
  19840. /**
  19841. * Define the camera used to render the texture.
  19842. */
  19843. activeCamera: Nullable<Camera>;
  19844. /**
  19845. * Override the render function of the texture with your own one.
  19846. */
  19847. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19848. /**
  19849. * Define if camera post processes should be use while rendering the texture.
  19850. */
  19851. useCameraPostProcesses: boolean;
  19852. /**
  19853. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19854. */
  19855. ignoreCameraViewport: boolean;
  19856. private _postProcessManager;
  19857. private _postProcesses;
  19858. private _resizeObserver;
  19859. /**
  19860. * An event triggered when the texture is unbind.
  19861. */
  19862. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19863. /**
  19864. * An event triggered when the texture is unbind.
  19865. */
  19866. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19867. private _onAfterUnbindObserver;
  19868. /**
  19869. * Set a after unbind callback in the texture.
  19870. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19871. */
  19872. onAfterUnbind: () => void;
  19873. /**
  19874. * An event triggered before rendering the texture
  19875. */
  19876. onBeforeRenderObservable: Observable<number>;
  19877. private _onBeforeRenderObserver;
  19878. /**
  19879. * Set a before render callback in the texture.
  19880. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19881. */
  19882. onBeforeRender: (faceIndex: number) => void;
  19883. /**
  19884. * An event triggered after rendering the texture
  19885. */
  19886. onAfterRenderObservable: Observable<number>;
  19887. private _onAfterRenderObserver;
  19888. /**
  19889. * Set a after render callback in the texture.
  19890. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19891. */
  19892. onAfterRender: (faceIndex: number) => void;
  19893. /**
  19894. * An event triggered after the texture clear
  19895. */
  19896. onClearObservable: Observable<Engine>;
  19897. private _onClearObserver;
  19898. /**
  19899. * Set a clear callback in the texture.
  19900. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19901. */
  19902. onClear: (Engine: Engine) => void;
  19903. /**
  19904. * An event triggered when the texture is resized.
  19905. */
  19906. onResizeObservable: Observable<RenderTargetTexture>;
  19907. /**
  19908. * Define the clear color of the Render Target if it should be different from the scene.
  19909. */
  19910. clearColor: Color4;
  19911. protected _size: number | {
  19912. width: number;
  19913. height: number;
  19914. };
  19915. protected _initialSizeParameter: number | {
  19916. width: number;
  19917. height: number;
  19918. } | {
  19919. ratio: number;
  19920. };
  19921. protected _sizeRatio: Nullable<number>;
  19922. /** @hidden */
  19923. _generateMipMaps: boolean;
  19924. protected _renderingManager: RenderingManager;
  19925. /** @hidden */
  19926. _waitingRenderList: string[];
  19927. protected _doNotChangeAspectRatio: boolean;
  19928. protected _currentRefreshId: number;
  19929. protected _refreshRate: number;
  19930. protected _textureMatrix: Matrix;
  19931. protected _samples: number;
  19932. protected _renderTargetOptions: RenderTargetCreationOptions;
  19933. /**
  19934. * Gets render target creation options that were used.
  19935. */
  19936. readonly renderTargetOptions: RenderTargetCreationOptions;
  19937. protected _engine: Engine;
  19938. protected _onRatioRescale(): void;
  19939. /**
  19940. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19941. * It must define where the camera used to render the texture is set
  19942. */
  19943. boundingBoxPosition: Vector3;
  19944. private _boundingBoxSize;
  19945. /**
  19946. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19947. * When defined, the cubemap will switch to local mode
  19948. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19949. * @example https://www.babylonjs-playground.com/#RNASML
  19950. */
  19951. boundingBoxSize: Vector3;
  19952. /**
  19953. * In case the RTT has been created with a depth texture, get the associated
  19954. * depth texture.
  19955. * Otherwise, return null.
  19956. */
  19957. depthStencilTexture: Nullable<InternalTexture>;
  19958. /**
  19959. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19960. * or used a shadow, depth texture...
  19961. * @param name The friendly name of the texture
  19962. * @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)
  19963. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19964. * @param generateMipMaps True if mip maps need to be generated after render.
  19965. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19966. * @param type The type of the buffer in the RTT (int, half float, float...)
  19967. * @param isCube True if a cube texture needs to be created
  19968. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19969. * @param generateDepthBuffer True to generate a depth buffer
  19970. * @param generateStencilBuffer True to generate a stencil buffer
  19971. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19972. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19973. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19974. */
  19975. constructor(name: string, size: number | {
  19976. width: number;
  19977. height: number;
  19978. } | {
  19979. ratio: number;
  19980. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19981. /**
  19982. * Creates a depth stencil texture.
  19983. * This is only available in WebGL 2 or with the depth texture extension available.
  19984. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19985. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19986. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19987. */
  19988. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19989. private _processSizeParameter;
  19990. /**
  19991. * Define the number of samples to use in case of MSAA.
  19992. * It defaults to one meaning no MSAA has been enabled.
  19993. */
  19994. samples: number;
  19995. /**
  19996. * Resets the refresh counter of the texture and start bak from scratch.
  19997. * Could be useful to regenerate the texture if it is setup to render only once.
  19998. */
  19999. resetRefreshCounter(): void;
  20000. /**
  20001. * Define the refresh rate of the texture or the rendering frequency.
  20002. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20003. */
  20004. refreshRate: number;
  20005. /**
  20006. * Adds a post process to the render target rendering passes.
  20007. * @param postProcess define the post process to add
  20008. */
  20009. addPostProcess(postProcess: PostProcess): void;
  20010. /**
  20011. * Clear all the post processes attached to the render target
  20012. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20013. */
  20014. clearPostProcesses(dispose?: boolean): void;
  20015. /**
  20016. * Remove one of the post process from the list of attached post processes to the texture
  20017. * @param postProcess define the post process to remove from the list
  20018. */
  20019. removePostProcess(postProcess: PostProcess): void;
  20020. /** @hidden */
  20021. _shouldRender(): boolean;
  20022. /**
  20023. * Gets the actual render size of the texture.
  20024. * @returns the width of the render size
  20025. */
  20026. getRenderSize(): number;
  20027. /**
  20028. * Gets the actual render width of the texture.
  20029. * @returns the width of the render size
  20030. */
  20031. getRenderWidth(): number;
  20032. /**
  20033. * Gets the actual render height of the texture.
  20034. * @returns the height of the render size
  20035. */
  20036. getRenderHeight(): number;
  20037. /**
  20038. * Get if the texture can be rescaled or not.
  20039. */
  20040. readonly canRescale: boolean;
  20041. /**
  20042. * Resize the texture using a ratio.
  20043. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20044. */
  20045. scale(ratio: number): void;
  20046. /**
  20047. * Get the texture reflection matrix used to rotate/transform the reflection.
  20048. * @returns the reflection matrix
  20049. */
  20050. getReflectionTextureMatrix(): Matrix;
  20051. /**
  20052. * Resize the texture to a new desired size.
  20053. * Be carrefull as it will recreate all the data in the new texture.
  20054. * @param size Define the new size. It can be:
  20055. * - a number for squared texture,
  20056. * - an object containing { width: number, height: number }
  20057. * - or an object containing a ratio { ratio: number }
  20058. */
  20059. resize(size: number | {
  20060. width: number;
  20061. height: number;
  20062. } | {
  20063. ratio: number;
  20064. }): void;
  20065. /**
  20066. * Renders all the objects from the render list into the texture.
  20067. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20068. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20069. */
  20070. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20071. private _bestReflectionRenderTargetDimension;
  20072. /**
  20073. * @hidden
  20074. * @param faceIndex face index to bind to if this is a cubetexture
  20075. */
  20076. _bindFrameBuffer(faceIndex?: number): void;
  20077. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20078. private renderToTarget;
  20079. /**
  20080. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20081. * This allowed control for front to back rendering or reversly depending of the special needs.
  20082. *
  20083. * @param renderingGroupId The rendering group id corresponding to its index
  20084. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20085. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20086. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20087. */
  20088. 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;
  20089. /**
  20090. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20091. *
  20092. * @param renderingGroupId The rendering group id corresponding to its index
  20093. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20094. */
  20095. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20096. /**
  20097. * Clones the texture.
  20098. * @returns the cloned texture
  20099. */
  20100. clone(): RenderTargetTexture;
  20101. /**
  20102. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20103. * @returns The JSON representation of the texture
  20104. */
  20105. serialize(): any;
  20106. /**
  20107. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20108. */
  20109. disposeFramebufferObjects(): void;
  20110. /**
  20111. * Dispose the texture and release its associated resources.
  20112. */
  20113. dispose(): void;
  20114. /** @hidden */
  20115. _rebuild(): void;
  20116. /**
  20117. * Clear the info related to rendering groups preventing retention point in material dispose.
  20118. */
  20119. freeRenderingGroups(): void;
  20120. /**
  20121. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20122. * @returns the view count
  20123. */
  20124. getViewCount(): number;
  20125. }
  20126. }
  20127. declare module BABYLON {
  20128. /**
  20129. * Base class for the main features of a material in Babylon.js
  20130. */
  20131. export class Material implements IAnimatable {
  20132. /**
  20133. * Returns the triangle fill mode
  20134. */
  20135. static readonly TriangleFillMode: number;
  20136. /**
  20137. * Returns the wireframe mode
  20138. */
  20139. static readonly WireFrameFillMode: number;
  20140. /**
  20141. * Returns the point fill mode
  20142. */
  20143. static readonly PointFillMode: number;
  20144. /**
  20145. * Returns the point list draw mode
  20146. */
  20147. static readonly PointListDrawMode: number;
  20148. /**
  20149. * Returns the line list draw mode
  20150. */
  20151. static readonly LineListDrawMode: number;
  20152. /**
  20153. * Returns the line loop draw mode
  20154. */
  20155. static readonly LineLoopDrawMode: number;
  20156. /**
  20157. * Returns the line strip draw mode
  20158. */
  20159. static readonly LineStripDrawMode: number;
  20160. /**
  20161. * Returns the triangle strip draw mode
  20162. */
  20163. static readonly TriangleStripDrawMode: number;
  20164. /**
  20165. * Returns the triangle fan draw mode
  20166. */
  20167. static readonly TriangleFanDrawMode: number;
  20168. /**
  20169. * Stores the clock-wise side orientation
  20170. */
  20171. static readonly ClockWiseSideOrientation: number;
  20172. /**
  20173. * Stores the counter clock-wise side orientation
  20174. */
  20175. static readonly CounterClockWiseSideOrientation: number;
  20176. /**
  20177. * The dirty texture flag value
  20178. */
  20179. static readonly TextureDirtyFlag: number;
  20180. /**
  20181. * The dirty light flag value
  20182. */
  20183. static readonly LightDirtyFlag: number;
  20184. /**
  20185. * The dirty fresnel flag value
  20186. */
  20187. static readonly FresnelDirtyFlag: number;
  20188. /**
  20189. * The dirty attribute flag value
  20190. */
  20191. static readonly AttributesDirtyFlag: number;
  20192. /**
  20193. * The dirty misc flag value
  20194. */
  20195. static readonly MiscDirtyFlag: number;
  20196. /**
  20197. * The all dirty flag value
  20198. */
  20199. static readonly AllDirtyFlag: number;
  20200. /**
  20201. * The ID of the material
  20202. */
  20203. id: string;
  20204. /**
  20205. * Gets or sets the unique id of the material
  20206. */
  20207. uniqueId: number;
  20208. /**
  20209. * The name of the material
  20210. */
  20211. name: string;
  20212. /**
  20213. * Gets or sets user defined metadata
  20214. */
  20215. metadata: any;
  20216. /**
  20217. * For internal use only. Please do not use.
  20218. */
  20219. reservedDataStore: any;
  20220. /**
  20221. * Specifies if the ready state should be checked on each call
  20222. */
  20223. checkReadyOnEveryCall: boolean;
  20224. /**
  20225. * Specifies if the ready state should be checked once
  20226. */
  20227. checkReadyOnlyOnce: boolean;
  20228. /**
  20229. * The state of the material
  20230. */
  20231. state: string;
  20232. /**
  20233. * The alpha value of the material
  20234. */
  20235. protected _alpha: number;
  20236. /**
  20237. * List of inspectable custom properties (used by the Inspector)
  20238. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20239. */
  20240. inspectableCustomProperties: IInspectable[];
  20241. /**
  20242. * Sets the alpha value of the material
  20243. */
  20244. /**
  20245. * Gets the alpha value of the material
  20246. */
  20247. alpha: number;
  20248. /**
  20249. * Specifies if back face culling is enabled
  20250. */
  20251. protected _backFaceCulling: boolean;
  20252. /**
  20253. * Sets the back-face culling state
  20254. */
  20255. /**
  20256. * Gets the back-face culling state
  20257. */
  20258. backFaceCulling: boolean;
  20259. /**
  20260. * Stores the value for side orientation
  20261. */
  20262. sideOrientation: number;
  20263. /**
  20264. * Callback triggered when the material is compiled
  20265. */
  20266. onCompiled: Nullable<(effect: Effect) => void>;
  20267. /**
  20268. * Callback triggered when an error occurs
  20269. */
  20270. onError: Nullable<(effect: Effect, errors: string) => void>;
  20271. /**
  20272. * Callback triggered to get the render target textures
  20273. */
  20274. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20275. /**
  20276. * Gets a boolean indicating that current material needs to register RTT
  20277. */
  20278. readonly hasRenderTargetTextures: boolean;
  20279. /**
  20280. * Specifies if the material should be serialized
  20281. */
  20282. doNotSerialize: boolean;
  20283. /**
  20284. * @hidden
  20285. */
  20286. _storeEffectOnSubMeshes: boolean;
  20287. /**
  20288. * Stores the animations for the material
  20289. */
  20290. animations: Nullable<Array<Animation>>;
  20291. /**
  20292. * An event triggered when the material is disposed
  20293. */
  20294. onDisposeObservable: Observable<Material>;
  20295. /**
  20296. * An observer which watches for dispose events
  20297. */
  20298. private _onDisposeObserver;
  20299. private _onUnBindObservable;
  20300. /**
  20301. * Called during a dispose event
  20302. */
  20303. onDispose: () => void;
  20304. private _onBindObservable;
  20305. /**
  20306. * An event triggered when the material is bound
  20307. */
  20308. readonly onBindObservable: Observable<AbstractMesh>;
  20309. /**
  20310. * An observer which watches for bind events
  20311. */
  20312. private _onBindObserver;
  20313. /**
  20314. * Called during a bind event
  20315. */
  20316. onBind: (Mesh: AbstractMesh) => void;
  20317. /**
  20318. * An event triggered when the material is unbound
  20319. */
  20320. readonly onUnBindObservable: Observable<Material>;
  20321. /**
  20322. * Stores the value of the alpha mode
  20323. */
  20324. private _alphaMode;
  20325. /**
  20326. * Sets the value of the alpha mode.
  20327. *
  20328. * | Value | Type | Description |
  20329. * | --- | --- | --- |
  20330. * | 0 | ALPHA_DISABLE | |
  20331. * | 1 | ALPHA_ADD | |
  20332. * | 2 | ALPHA_COMBINE | |
  20333. * | 3 | ALPHA_SUBTRACT | |
  20334. * | 4 | ALPHA_MULTIPLY | |
  20335. * | 5 | ALPHA_MAXIMIZED | |
  20336. * | 6 | ALPHA_ONEONE | |
  20337. * | 7 | ALPHA_PREMULTIPLIED | |
  20338. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20339. * | 9 | ALPHA_INTERPOLATE | |
  20340. * | 10 | ALPHA_SCREENMODE | |
  20341. *
  20342. */
  20343. /**
  20344. * Gets the value of the alpha mode
  20345. */
  20346. alphaMode: number;
  20347. /**
  20348. * Stores the state of the need depth pre-pass value
  20349. */
  20350. private _needDepthPrePass;
  20351. /**
  20352. * Sets the need depth pre-pass value
  20353. */
  20354. /**
  20355. * Gets the depth pre-pass value
  20356. */
  20357. needDepthPrePass: boolean;
  20358. /**
  20359. * Specifies if depth writing should be disabled
  20360. */
  20361. disableDepthWrite: boolean;
  20362. /**
  20363. * Specifies if depth writing should be forced
  20364. */
  20365. forceDepthWrite: boolean;
  20366. /**
  20367. * Specifies if there should be a separate pass for culling
  20368. */
  20369. separateCullingPass: boolean;
  20370. /**
  20371. * Stores the state specifing if fog should be enabled
  20372. */
  20373. private _fogEnabled;
  20374. /**
  20375. * Sets the state for enabling fog
  20376. */
  20377. /**
  20378. * Gets the value of the fog enabled state
  20379. */
  20380. fogEnabled: boolean;
  20381. /**
  20382. * Stores the size of points
  20383. */
  20384. pointSize: number;
  20385. /**
  20386. * Stores the z offset value
  20387. */
  20388. zOffset: number;
  20389. /**
  20390. * Gets a value specifying if wireframe mode is enabled
  20391. */
  20392. /**
  20393. * Sets the state of wireframe mode
  20394. */
  20395. wireframe: boolean;
  20396. /**
  20397. * Gets the value specifying if point clouds are enabled
  20398. */
  20399. /**
  20400. * Sets the state of point cloud mode
  20401. */
  20402. pointsCloud: boolean;
  20403. /**
  20404. * Gets the material fill mode
  20405. */
  20406. /**
  20407. * Sets the material fill mode
  20408. */
  20409. fillMode: number;
  20410. /**
  20411. * @hidden
  20412. * Stores the effects for the material
  20413. */
  20414. _effect: Nullable<Effect>;
  20415. /**
  20416. * @hidden
  20417. * Specifies if the material was previously ready
  20418. */
  20419. _wasPreviouslyReady: boolean;
  20420. /**
  20421. * Specifies if uniform buffers should be used
  20422. */
  20423. private _useUBO;
  20424. /**
  20425. * Stores a reference to the scene
  20426. */
  20427. private _scene;
  20428. /**
  20429. * Stores the fill mode state
  20430. */
  20431. private _fillMode;
  20432. /**
  20433. * Specifies if the depth write state should be cached
  20434. */
  20435. private _cachedDepthWriteState;
  20436. /**
  20437. * Stores the uniform buffer
  20438. */
  20439. protected _uniformBuffer: UniformBuffer;
  20440. /** @hidden */
  20441. _indexInSceneMaterialArray: number;
  20442. /** @hidden */
  20443. meshMap: Nullable<{
  20444. [id: string]: AbstractMesh | undefined;
  20445. }>;
  20446. /**
  20447. * Creates a material instance
  20448. * @param name defines the name of the material
  20449. * @param scene defines the scene to reference
  20450. * @param doNotAdd specifies if the material should be added to the scene
  20451. */
  20452. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20453. /**
  20454. * Returns a string representation of the current material
  20455. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20456. * @returns a string with material information
  20457. */
  20458. toString(fullDetails?: boolean): string;
  20459. /**
  20460. * Gets the class name of the material
  20461. * @returns a string with the class name of the material
  20462. */
  20463. getClassName(): string;
  20464. /**
  20465. * Specifies if updates for the material been locked
  20466. */
  20467. readonly isFrozen: boolean;
  20468. /**
  20469. * Locks updates for the material
  20470. */
  20471. freeze(): void;
  20472. /**
  20473. * Unlocks updates for the material
  20474. */
  20475. unfreeze(): void;
  20476. /**
  20477. * Specifies if the material is ready to be used
  20478. * @param mesh defines the mesh to check
  20479. * @param useInstances specifies if instances should be used
  20480. * @returns a boolean indicating if the material is ready to be used
  20481. */
  20482. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20483. /**
  20484. * Specifies that the submesh is ready to be used
  20485. * @param mesh defines the mesh to check
  20486. * @param subMesh defines which submesh to check
  20487. * @param useInstances specifies that instances should be used
  20488. * @returns a boolean indicating that the submesh is ready or not
  20489. */
  20490. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20491. /**
  20492. * Returns the material effect
  20493. * @returns the effect associated with the material
  20494. */
  20495. getEffect(): Nullable<Effect>;
  20496. /**
  20497. * Returns the current scene
  20498. * @returns a Scene
  20499. */
  20500. getScene(): Scene;
  20501. /**
  20502. * Specifies if the material will require alpha blending
  20503. * @returns a boolean specifying if alpha blending is needed
  20504. */
  20505. needAlphaBlending(): boolean;
  20506. /**
  20507. * Specifies if the mesh will require alpha blending
  20508. * @param mesh defines the mesh to check
  20509. * @returns a boolean specifying if alpha blending is needed for the mesh
  20510. */
  20511. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20512. /**
  20513. * Specifies if this material should be rendered in alpha test mode
  20514. * @returns a boolean specifying if an alpha test is needed.
  20515. */
  20516. needAlphaTesting(): boolean;
  20517. /**
  20518. * Gets the texture used for the alpha test
  20519. * @returns the texture to use for alpha testing
  20520. */
  20521. getAlphaTestTexture(): Nullable<BaseTexture>;
  20522. /**
  20523. * Marks the material to indicate that it needs to be re-calculated
  20524. */
  20525. markDirty(): void;
  20526. /** @hidden */
  20527. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20528. /**
  20529. * Binds the material to the mesh
  20530. * @param world defines the world transformation matrix
  20531. * @param mesh defines the mesh to bind the material to
  20532. */
  20533. bind(world: Matrix, mesh?: Mesh): void;
  20534. /**
  20535. * Binds the submesh to the material
  20536. * @param world defines the world transformation matrix
  20537. * @param mesh defines the mesh containing the submesh
  20538. * @param subMesh defines the submesh to bind the material to
  20539. */
  20540. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20541. /**
  20542. * Binds the world matrix to the material
  20543. * @param world defines the world transformation matrix
  20544. */
  20545. bindOnlyWorldMatrix(world: Matrix): void;
  20546. /**
  20547. * Binds the scene's uniform buffer to the effect.
  20548. * @param effect defines the effect to bind to the scene uniform buffer
  20549. * @param sceneUbo defines the uniform buffer storing scene data
  20550. */
  20551. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20552. /**
  20553. * Binds the view matrix to the effect
  20554. * @param effect defines the effect to bind the view matrix to
  20555. */
  20556. bindView(effect: Effect): void;
  20557. /**
  20558. * Binds the view projection matrix to the effect
  20559. * @param effect defines the effect to bind the view projection matrix to
  20560. */
  20561. bindViewProjection(effect: Effect): void;
  20562. /**
  20563. * Specifies if material alpha testing should be turned on for the mesh
  20564. * @param mesh defines the mesh to check
  20565. */
  20566. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20567. /**
  20568. * Processes to execute after binding the material to a mesh
  20569. * @param mesh defines the rendered mesh
  20570. */
  20571. protected _afterBind(mesh?: Mesh): void;
  20572. /**
  20573. * Unbinds the material from the mesh
  20574. */
  20575. unbind(): void;
  20576. /**
  20577. * Gets the active textures from the material
  20578. * @returns an array of textures
  20579. */
  20580. getActiveTextures(): BaseTexture[];
  20581. /**
  20582. * Specifies if the material uses a texture
  20583. * @param texture defines the texture to check against the material
  20584. * @returns a boolean specifying if the material uses the texture
  20585. */
  20586. hasTexture(texture: BaseTexture): boolean;
  20587. /**
  20588. * Makes a duplicate of the material, and gives it a new name
  20589. * @param name defines the new name for the duplicated material
  20590. * @returns the cloned material
  20591. */
  20592. clone(name: string): Nullable<Material>;
  20593. /**
  20594. * Gets the meshes bound to the material
  20595. * @returns an array of meshes bound to the material
  20596. */
  20597. getBindedMeshes(): AbstractMesh[];
  20598. /**
  20599. * Force shader compilation
  20600. * @param mesh defines the mesh associated with this material
  20601. * @param onCompiled defines a function to execute once the material is compiled
  20602. * @param options defines the options to configure the compilation
  20603. */
  20604. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20605. clipPlane: boolean;
  20606. }>): void;
  20607. /**
  20608. * Force shader compilation
  20609. * @param mesh defines the mesh that will use this material
  20610. * @param options defines additional options for compiling the shaders
  20611. * @returns a promise that resolves when the compilation completes
  20612. */
  20613. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20614. clipPlane: boolean;
  20615. }>): Promise<void>;
  20616. private static readonly _AllDirtyCallBack;
  20617. private static readonly _ImageProcessingDirtyCallBack;
  20618. private static readonly _TextureDirtyCallBack;
  20619. private static readonly _FresnelDirtyCallBack;
  20620. private static readonly _MiscDirtyCallBack;
  20621. private static readonly _LightsDirtyCallBack;
  20622. private static readonly _AttributeDirtyCallBack;
  20623. private static _FresnelAndMiscDirtyCallBack;
  20624. private static _TextureAndMiscDirtyCallBack;
  20625. private static readonly _DirtyCallbackArray;
  20626. private static readonly _RunDirtyCallBacks;
  20627. /**
  20628. * Marks a define in the material to indicate that it needs to be re-computed
  20629. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20630. */
  20631. markAsDirty(flag: number): void;
  20632. /**
  20633. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20634. * @param func defines a function which checks material defines against the submeshes
  20635. */
  20636. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20637. /**
  20638. * Indicates that we need to re-calculated for all submeshes
  20639. */
  20640. protected _markAllSubMeshesAsAllDirty(): void;
  20641. /**
  20642. * Indicates that image processing needs to be re-calculated for all submeshes
  20643. */
  20644. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20645. /**
  20646. * Indicates that textures need to be re-calculated for all submeshes
  20647. */
  20648. protected _markAllSubMeshesAsTexturesDirty(): void;
  20649. /**
  20650. * Indicates that fresnel needs to be re-calculated for all submeshes
  20651. */
  20652. protected _markAllSubMeshesAsFresnelDirty(): void;
  20653. /**
  20654. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20655. */
  20656. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20657. /**
  20658. * Indicates that lights need to be re-calculated for all submeshes
  20659. */
  20660. protected _markAllSubMeshesAsLightsDirty(): void;
  20661. /**
  20662. * Indicates that attributes need to be re-calculated for all submeshes
  20663. */
  20664. protected _markAllSubMeshesAsAttributesDirty(): void;
  20665. /**
  20666. * Indicates that misc needs to be re-calculated for all submeshes
  20667. */
  20668. protected _markAllSubMeshesAsMiscDirty(): void;
  20669. /**
  20670. * Indicates that textures and misc need to be re-calculated for all submeshes
  20671. */
  20672. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20673. /**
  20674. * Disposes the material
  20675. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20676. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20677. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20678. */
  20679. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20680. /** @hidden */
  20681. private releaseVertexArrayObject;
  20682. /**
  20683. * Serializes this material
  20684. * @returns the serialized material object
  20685. */
  20686. serialize(): any;
  20687. /**
  20688. * Creates a material from parsed material data
  20689. * @param parsedMaterial defines parsed material data
  20690. * @param scene defines the hosting scene
  20691. * @param rootUrl defines the root URL to use to load textures
  20692. * @returns a new material
  20693. */
  20694. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20695. }
  20696. }
  20697. declare module BABYLON {
  20698. /**
  20699. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20700. * separate meshes. This can be use to improve performances.
  20701. * @see http://doc.babylonjs.com/how_to/multi_materials
  20702. */
  20703. export class MultiMaterial extends Material {
  20704. private _subMaterials;
  20705. /**
  20706. * Gets or Sets the list of Materials used within the multi material.
  20707. * They need to be ordered according to the submeshes order in the associated mesh
  20708. */
  20709. subMaterials: Nullable<Material>[];
  20710. /**
  20711. * Function used to align with Node.getChildren()
  20712. * @returns the list of Materials used within the multi material
  20713. */
  20714. getChildren(): Nullable<Material>[];
  20715. /**
  20716. * Instantiates a new Multi Material
  20717. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20718. * separate meshes. This can be use to improve performances.
  20719. * @see http://doc.babylonjs.com/how_to/multi_materials
  20720. * @param name Define the name in the scene
  20721. * @param scene Define the scene the material belongs to
  20722. */
  20723. constructor(name: string, scene: Scene);
  20724. private _hookArray;
  20725. /**
  20726. * Get one of the submaterial by its index in the submaterials array
  20727. * @param index The index to look the sub material at
  20728. * @returns The Material if the index has been defined
  20729. */
  20730. getSubMaterial(index: number): Nullable<Material>;
  20731. /**
  20732. * Get the list of active textures for the whole sub materials list.
  20733. * @returns All the textures that will be used during the rendering
  20734. */
  20735. getActiveTextures(): BaseTexture[];
  20736. /**
  20737. * Gets the current class name of the material e.g. "MultiMaterial"
  20738. * Mainly use in serialization.
  20739. * @returns the class name
  20740. */
  20741. getClassName(): string;
  20742. /**
  20743. * Checks if the material is ready to render the requested sub mesh
  20744. * @param mesh Define the mesh the submesh belongs to
  20745. * @param subMesh Define the sub mesh to look readyness for
  20746. * @param useInstances Define whether or not the material is used with instances
  20747. * @returns true if ready, otherwise false
  20748. */
  20749. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20750. /**
  20751. * Clones the current material and its related sub materials
  20752. * @param name Define the name of the newly cloned material
  20753. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20754. * @returns the cloned material
  20755. */
  20756. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20757. /**
  20758. * Serializes the materials into a JSON representation.
  20759. * @returns the JSON representation
  20760. */
  20761. serialize(): any;
  20762. /**
  20763. * Dispose the material and release its associated resources
  20764. * @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)
  20765. * @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)
  20766. * @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)
  20767. */
  20768. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20769. /**
  20770. * Creates a MultiMaterial from parsed MultiMaterial data.
  20771. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20772. * @param scene defines the hosting scene
  20773. * @returns a new MultiMaterial
  20774. */
  20775. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20776. }
  20777. }
  20778. declare module BABYLON {
  20779. /**
  20780. * Base class for submeshes
  20781. */
  20782. export class BaseSubMesh {
  20783. /** @hidden */
  20784. _materialDefines: Nullable<MaterialDefines>;
  20785. /** @hidden */
  20786. _materialEffect: Nullable<Effect>;
  20787. /**
  20788. * Gets associated effect
  20789. */
  20790. readonly effect: Nullable<Effect>;
  20791. /**
  20792. * Sets associated effect (effect used to render this submesh)
  20793. * @param effect defines the effect to associate with
  20794. * @param defines defines the set of defines used to compile this effect
  20795. */
  20796. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20797. }
  20798. /**
  20799. * Defines a subdivision inside a mesh
  20800. */
  20801. export class SubMesh extends BaseSubMesh implements ICullable {
  20802. /** the material index to use */
  20803. materialIndex: number;
  20804. /** vertex index start */
  20805. verticesStart: number;
  20806. /** vertices count */
  20807. verticesCount: number;
  20808. /** index start */
  20809. indexStart: number;
  20810. /** indices count */
  20811. indexCount: number;
  20812. /** @hidden */
  20813. _linesIndexCount: number;
  20814. private _mesh;
  20815. private _renderingMesh;
  20816. private _boundingInfo;
  20817. private _linesIndexBuffer;
  20818. /** @hidden */
  20819. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20820. /** @hidden */
  20821. _trianglePlanes: Plane[];
  20822. /** @hidden */
  20823. _lastColliderTransformMatrix: Nullable<Matrix>;
  20824. /** @hidden */
  20825. _renderId: number;
  20826. /** @hidden */
  20827. _alphaIndex: number;
  20828. /** @hidden */
  20829. _distanceToCamera: number;
  20830. /** @hidden */
  20831. _id: number;
  20832. private _currentMaterial;
  20833. /**
  20834. * Add a new submesh to a mesh
  20835. * @param materialIndex defines the material index to use
  20836. * @param verticesStart defines vertex index start
  20837. * @param verticesCount defines vertices count
  20838. * @param indexStart defines index start
  20839. * @param indexCount defines indices count
  20840. * @param mesh defines the parent mesh
  20841. * @param renderingMesh defines an optional rendering mesh
  20842. * @param createBoundingBox defines if bounding box should be created for this submesh
  20843. * @returns the new submesh
  20844. */
  20845. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20846. /**
  20847. * Creates a new submesh
  20848. * @param materialIndex defines the material index to use
  20849. * @param verticesStart defines vertex index start
  20850. * @param verticesCount defines vertices count
  20851. * @param indexStart defines index start
  20852. * @param indexCount defines indices count
  20853. * @param mesh defines the parent mesh
  20854. * @param renderingMesh defines an optional rendering mesh
  20855. * @param createBoundingBox defines if bounding box should be created for this submesh
  20856. */
  20857. constructor(
  20858. /** the material index to use */
  20859. materialIndex: number,
  20860. /** vertex index start */
  20861. verticesStart: number,
  20862. /** vertices count */
  20863. verticesCount: number,
  20864. /** index start */
  20865. indexStart: number,
  20866. /** indices count */
  20867. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20868. /**
  20869. * Returns true if this submesh covers the entire parent mesh
  20870. * @ignorenaming
  20871. */
  20872. readonly IsGlobal: boolean;
  20873. /**
  20874. * Returns the submesh BoudingInfo object
  20875. * @returns current bounding info (or mesh's one if the submesh is global)
  20876. */
  20877. getBoundingInfo(): BoundingInfo;
  20878. /**
  20879. * Sets the submesh BoundingInfo
  20880. * @param boundingInfo defines the new bounding info to use
  20881. * @returns the SubMesh
  20882. */
  20883. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20884. /**
  20885. * Returns the mesh of the current submesh
  20886. * @return the parent mesh
  20887. */
  20888. getMesh(): AbstractMesh;
  20889. /**
  20890. * Returns the rendering mesh of the submesh
  20891. * @returns the rendering mesh (could be different from parent mesh)
  20892. */
  20893. getRenderingMesh(): Mesh;
  20894. /**
  20895. * Returns the submesh material
  20896. * @returns null or the current material
  20897. */
  20898. getMaterial(): Nullable<Material>;
  20899. /**
  20900. * Sets a new updated BoundingInfo object to the submesh
  20901. * @param data defines an optional position array to use to determine the bounding info
  20902. * @returns the SubMesh
  20903. */
  20904. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20905. /** @hidden */
  20906. _checkCollision(collider: Collider): boolean;
  20907. /**
  20908. * Updates the submesh BoundingInfo
  20909. * @param world defines the world matrix to use to update the bounding info
  20910. * @returns the submesh
  20911. */
  20912. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20913. /**
  20914. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20915. * @param frustumPlanes defines the frustum planes
  20916. * @returns true if the submesh is intersecting with the frustum
  20917. */
  20918. isInFrustum(frustumPlanes: Plane[]): boolean;
  20919. /**
  20920. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20921. * @param frustumPlanes defines the frustum planes
  20922. * @returns true if the submesh is inside the frustum
  20923. */
  20924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20925. /**
  20926. * Renders the submesh
  20927. * @param enableAlphaMode defines if alpha needs to be used
  20928. * @returns the submesh
  20929. */
  20930. render(enableAlphaMode: boolean): SubMesh;
  20931. /**
  20932. * @hidden
  20933. */
  20934. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20935. /**
  20936. * Checks if the submesh intersects with a ray
  20937. * @param ray defines the ray to test
  20938. * @returns true is the passed ray intersects the submesh bounding box
  20939. */
  20940. canIntersects(ray: Ray): boolean;
  20941. /**
  20942. * Intersects current submesh with a ray
  20943. * @param ray defines the ray to test
  20944. * @param positions defines mesh's positions array
  20945. * @param indices defines mesh's indices array
  20946. * @param fastCheck defines if only bounding info should be used
  20947. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20948. * @returns intersection info or null if no intersection
  20949. */
  20950. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20951. /** @hidden */
  20952. private _intersectLines;
  20953. /** @hidden */
  20954. private _intersectUnIndexedLines;
  20955. /** @hidden */
  20956. private _intersectTriangles;
  20957. /** @hidden */
  20958. private _intersectUnIndexedTriangles;
  20959. /** @hidden */
  20960. _rebuild(): void;
  20961. /**
  20962. * Creates a new submesh from the passed mesh
  20963. * @param newMesh defines the new hosting mesh
  20964. * @param newRenderingMesh defines an optional rendering mesh
  20965. * @returns the new submesh
  20966. */
  20967. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20968. /**
  20969. * Release associated resources
  20970. */
  20971. dispose(): void;
  20972. /**
  20973. * Gets the class name
  20974. * @returns the string "SubMesh".
  20975. */
  20976. getClassName(): string;
  20977. /**
  20978. * Creates a new submesh from indices data
  20979. * @param materialIndex the index of the main mesh material
  20980. * @param startIndex the index where to start the copy in the mesh indices array
  20981. * @param indexCount the number of indices to copy then from the startIndex
  20982. * @param mesh the main mesh to create the submesh from
  20983. * @param renderingMesh the optional rendering mesh
  20984. * @returns a new submesh
  20985. */
  20986. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20987. }
  20988. }
  20989. declare module BABYLON {
  20990. /**
  20991. * Class used to represent data loading progression
  20992. */
  20993. export class SceneLoaderFlags {
  20994. private static _ForceFullSceneLoadingForIncremental;
  20995. private static _ShowLoadingScreen;
  20996. private static _CleanBoneMatrixWeights;
  20997. private static _loggingLevel;
  20998. /**
  20999. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21000. */
  21001. static ForceFullSceneLoadingForIncremental: boolean;
  21002. /**
  21003. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21004. */
  21005. static ShowLoadingScreen: boolean;
  21006. /**
  21007. * Defines the current logging level (while loading the scene)
  21008. * @ignorenaming
  21009. */
  21010. static loggingLevel: number;
  21011. /**
  21012. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21013. */
  21014. static CleanBoneMatrixWeights: boolean;
  21015. }
  21016. }
  21017. declare module BABYLON {
  21018. /**
  21019. * Class used to store geometry data (vertex buffers + index buffer)
  21020. */
  21021. export class Geometry implements IGetSetVerticesData {
  21022. /**
  21023. * Gets or sets the ID of the geometry
  21024. */
  21025. id: string;
  21026. /**
  21027. * Gets or sets the unique ID of the geometry
  21028. */
  21029. uniqueId: number;
  21030. /**
  21031. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21032. */
  21033. delayLoadState: number;
  21034. /**
  21035. * Gets the file containing the data to load when running in delay load state
  21036. */
  21037. delayLoadingFile: Nullable<string>;
  21038. /**
  21039. * Callback called when the geometry is updated
  21040. */
  21041. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21042. private _scene;
  21043. private _engine;
  21044. private _meshes;
  21045. private _totalVertices;
  21046. /** @hidden */
  21047. _indices: IndicesArray;
  21048. /** @hidden */
  21049. _vertexBuffers: {
  21050. [key: string]: VertexBuffer;
  21051. };
  21052. private _isDisposed;
  21053. private _extend;
  21054. private _boundingBias;
  21055. /** @hidden */
  21056. _delayInfo: Array<string>;
  21057. private _indexBuffer;
  21058. private _indexBufferIsUpdatable;
  21059. /** @hidden */
  21060. _boundingInfo: Nullable<BoundingInfo>;
  21061. /** @hidden */
  21062. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21063. /** @hidden */
  21064. _softwareSkinningFrameId: number;
  21065. private _vertexArrayObjects;
  21066. private _updatable;
  21067. /** @hidden */
  21068. _positions: Nullable<Vector3[]>;
  21069. /**
  21070. * 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
  21071. */
  21072. /**
  21073. * 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
  21074. */
  21075. boundingBias: Vector2;
  21076. /**
  21077. * Static function used to attach a new empty geometry to a mesh
  21078. * @param mesh defines the mesh to attach the geometry to
  21079. * @returns the new Geometry
  21080. */
  21081. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21082. /**
  21083. * Creates a new geometry
  21084. * @param id defines the unique ID
  21085. * @param scene defines the hosting scene
  21086. * @param vertexData defines the VertexData used to get geometry data
  21087. * @param updatable defines if geometry must be updatable (false by default)
  21088. * @param mesh defines the mesh that will be associated with the geometry
  21089. */
  21090. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21091. /**
  21092. * Gets the current extend of the geometry
  21093. */
  21094. readonly extend: {
  21095. minimum: Vector3;
  21096. maximum: Vector3;
  21097. };
  21098. /**
  21099. * Gets the hosting scene
  21100. * @returns the hosting Scene
  21101. */
  21102. getScene(): Scene;
  21103. /**
  21104. * Gets the hosting engine
  21105. * @returns the hosting Engine
  21106. */
  21107. getEngine(): Engine;
  21108. /**
  21109. * Defines if the geometry is ready to use
  21110. * @returns true if the geometry is ready to be used
  21111. */
  21112. isReady(): boolean;
  21113. /**
  21114. * Gets a value indicating that the geometry should not be serialized
  21115. */
  21116. readonly doNotSerialize: boolean;
  21117. /** @hidden */
  21118. _rebuild(): void;
  21119. /**
  21120. * Affects all geometry data in one call
  21121. * @param vertexData defines the geometry data
  21122. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21123. */
  21124. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21125. /**
  21126. * Set specific vertex data
  21127. * @param kind defines the data kind (Position, normal, etc...)
  21128. * @param data defines the vertex data to use
  21129. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21130. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21131. */
  21132. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21133. /**
  21134. * Removes a specific vertex data
  21135. * @param kind defines the data kind (Position, normal, etc...)
  21136. */
  21137. removeVerticesData(kind: string): void;
  21138. /**
  21139. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21140. * @param buffer defines the vertex buffer to use
  21141. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21142. */
  21143. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21144. /**
  21145. * Update a specific vertex buffer
  21146. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21147. * It will do nothing if the buffer is not updatable
  21148. * @param kind defines the data kind (Position, normal, etc...)
  21149. * @param data defines the data to use
  21150. * @param offset defines the offset in the target buffer where to store the data
  21151. * @param useBytes set to true if the offset is in bytes
  21152. */
  21153. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21154. /**
  21155. * Update a specific vertex buffer
  21156. * This function will create a new buffer if the current one is not updatable
  21157. * @param kind defines the data kind (Position, normal, etc...)
  21158. * @param data defines the data to use
  21159. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21160. */
  21161. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21162. private _updateBoundingInfo;
  21163. /** @hidden */
  21164. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21165. /**
  21166. * Gets total number of vertices
  21167. * @returns the total number of vertices
  21168. */
  21169. getTotalVertices(): number;
  21170. /**
  21171. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21172. * @param kind defines the data kind (Position, normal, etc...)
  21173. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21174. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21175. * @returns a float array containing vertex data
  21176. */
  21177. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21178. /**
  21179. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21180. * @param kind defines the data kind (Position, normal, etc...)
  21181. * @returns true if the vertex buffer with the specified kind is updatable
  21182. */
  21183. isVertexBufferUpdatable(kind: string): boolean;
  21184. /**
  21185. * Gets a specific vertex buffer
  21186. * @param kind defines the data kind (Position, normal, etc...)
  21187. * @returns a VertexBuffer
  21188. */
  21189. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21190. /**
  21191. * Returns all vertex buffers
  21192. * @return an object holding all vertex buffers indexed by kind
  21193. */
  21194. getVertexBuffers(): Nullable<{
  21195. [key: string]: VertexBuffer;
  21196. }>;
  21197. /**
  21198. * Gets a boolean indicating if specific vertex buffer is present
  21199. * @param kind defines the data kind (Position, normal, etc...)
  21200. * @returns true if data is present
  21201. */
  21202. isVerticesDataPresent(kind: string): boolean;
  21203. /**
  21204. * Gets a list of all attached data kinds (Position, normal, etc...)
  21205. * @returns a list of string containing all kinds
  21206. */
  21207. getVerticesDataKinds(): string[];
  21208. /**
  21209. * Update index buffer
  21210. * @param indices defines the indices to store in the index buffer
  21211. * @param offset defines the offset in the target buffer where to store the data
  21212. * @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)
  21213. */
  21214. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21215. /**
  21216. * Creates a new index buffer
  21217. * @param indices defines the indices to store in the index buffer
  21218. * @param totalVertices defines the total number of vertices (could be null)
  21219. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21220. */
  21221. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21222. /**
  21223. * Return the total number of indices
  21224. * @returns the total number of indices
  21225. */
  21226. getTotalIndices(): number;
  21227. /**
  21228. * Gets the index buffer array
  21229. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21231. * @returns the index buffer array
  21232. */
  21233. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21234. /**
  21235. * Gets the index buffer
  21236. * @return the index buffer
  21237. */
  21238. getIndexBuffer(): Nullable<DataBuffer>;
  21239. /** @hidden */
  21240. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21241. /**
  21242. * Release the associated resources for a specific mesh
  21243. * @param mesh defines the source mesh
  21244. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21245. */
  21246. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21247. /**
  21248. * Apply current geometry to a given mesh
  21249. * @param mesh defines the mesh to apply geometry to
  21250. */
  21251. applyToMesh(mesh: Mesh): void;
  21252. private _updateExtend;
  21253. private _applyToMesh;
  21254. private notifyUpdate;
  21255. /**
  21256. * Load the geometry if it was flagged as delay loaded
  21257. * @param scene defines the hosting scene
  21258. * @param onLoaded defines a callback called when the geometry is loaded
  21259. */
  21260. load(scene: Scene, onLoaded?: () => void): void;
  21261. private _queueLoad;
  21262. /**
  21263. * Invert the geometry to move from a right handed system to a left handed one.
  21264. */
  21265. toLeftHanded(): void;
  21266. /** @hidden */
  21267. _resetPointsArrayCache(): void;
  21268. /** @hidden */
  21269. _generatePointsArray(): boolean;
  21270. /**
  21271. * Gets a value indicating if the geometry is disposed
  21272. * @returns true if the geometry was disposed
  21273. */
  21274. isDisposed(): boolean;
  21275. private _disposeVertexArrayObjects;
  21276. /**
  21277. * Free all associated resources
  21278. */
  21279. dispose(): void;
  21280. /**
  21281. * Clone the current geometry into a new geometry
  21282. * @param id defines the unique ID of the new geometry
  21283. * @returns a new geometry object
  21284. */
  21285. copy(id: string): Geometry;
  21286. /**
  21287. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21288. * @return a JSON representation of the current geometry data (without the vertices data)
  21289. */
  21290. serialize(): any;
  21291. private toNumberArray;
  21292. /**
  21293. * Serialize all vertices data into a JSON oject
  21294. * @returns a JSON representation of the current geometry data
  21295. */
  21296. serializeVerticeData(): any;
  21297. /**
  21298. * Extracts a clone of a mesh geometry
  21299. * @param mesh defines the source mesh
  21300. * @param id defines the unique ID of the new geometry object
  21301. * @returns the new geometry object
  21302. */
  21303. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21304. /**
  21305. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21306. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21307. * Be aware Math.random() could cause collisions, but:
  21308. * "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"
  21309. * @returns a string containing a new GUID
  21310. */
  21311. static RandomId(): string;
  21312. /** @hidden */
  21313. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21314. private static _CleanMatricesWeights;
  21315. /**
  21316. * Create a new geometry from persisted data (Using .babylon file format)
  21317. * @param parsedVertexData defines the persisted data
  21318. * @param scene defines the hosting scene
  21319. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21320. * @returns the new geometry object
  21321. */
  21322. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21323. }
  21324. }
  21325. declare module BABYLON {
  21326. /**
  21327. * Define an interface for all classes that will get and set the data on vertices
  21328. */
  21329. export interface IGetSetVerticesData {
  21330. /**
  21331. * Gets a boolean indicating if specific vertex data is present
  21332. * @param kind defines the vertex data kind to use
  21333. * @returns true is data kind is present
  21334. */
  21335. isVerticesDataPresent(kind: string): boolean;
  21336. /**
  21337. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21338. * @param kind defines the data kind (Position, normal, etc...)
  21339. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21341. * @returns a float array containing vertex data
  21342. */
  21343. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21344. /**
  21345. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21346. * @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.
  21347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21348. * @returns the indices array or an empty array if the mesh has no geometry
  21349. */
  21350. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21351. /**
  21352. * Set specific vertex data
  21353. * @param kind defines the data kind (Position, normal, etc...)
  21354. * @param data defines the vertex data to use
  21355. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21356. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21357. */
  21358. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21359. /**
  21360. * Update a specific associated vertex buffer
  21361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21362. * - VertexBuffer.PositionKind
  21363. * - VertexBuffer.UVKind
  21364. * - VertexBuffer.UV2Kind
  21365. * - VertexBuffer.UV3Kind
  21366. * - VertexBuffer.UV4Kind
  21367. * - VertexBuffer.UV5Kind
  21368. * - VertexBuffer.UV6Kind
  21369. * - VertexBuffer.ColorKind
  21370. * - VertexBuffer.MatricesIndicesKind
  21371. * - VertexBuffer.MatricesIndicesExtraKind
  21372. * - VertexBuffer.MatricesWeightsKind
  21373. * - VertexBuffer.MatricesWeightsExtraKind
  21374. * @param data defines the data source
  21375. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21376. * @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)
  21377. */
  21378. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21379. /**
  21380. * Creates a new index buffer
  21381. * @param indices defines the indices to store in the index buffer
  21382. * @param totalVertices defines the total number of vertices (could be null)
  21383. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21384. */
  21385. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21386. }
  21387. /**
  21388. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21389. */
  21390. export class VertexData {
  21391. /**
  21392. * Mesh side orientation : usually the external or front surface
  21393. */
  21394. static readonly FRONTSIDE: number;
  21395. /**
  21396. * Mesh side orientation : usually the internal or back surface
  21397. */
  21398. static readonly BACKSIDE: number;
  21399. /**
  21400. * Mesh side orientation : both internal and external or front and back surfaces
  21401. */
  21402. static readonly DOUBLESIDE: number;
  21403. /**
  21404. * Mesh side orientation : by default, `FRONTSIDE`
  21405. */
  21406. static readonly DEFAULTSIDE: number;
  21407. /**
  21408. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21409. */
  21410. positions: Nullable<FloatArray>;
  21411. /**
  21412. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21413. */
  21414. normals: Nullable<FloatArray>;
  21415. /**
  21416. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21417. */
  21418. tangents: Nullable<FloatArray>;
  21419. /**
  21420. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21421. */
  21422. uvs: Nullable<FloatArray>;
  21423. /**
  21424. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21425. */
  21426. uvs2: Nullable<FloatArray>;
  21427. /**
  21428. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21429. */
  21430. uvs3: Nullable<FloatArray>;
  21431. /**
  21432. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21433. */
  21434. uvs4: Nullable<FloatArray>;
  21435. /**
  21436. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21437. */
  21438. uvs5: Nullable<FloatArray>;
  21439. /**
  21440. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21441. */
  21442. uvs6: Nullable<FloatArray>;
  21443. /**
  21444. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21445. */
  21446. colors: Nullable<FloatArray>;
  21447. /**
  21448. * 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).
  21449. */
  21450. matricesIndices: Nullable<FloatArray>;
  21451. /**
  21452. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21453. */
  21454. matricesWeights: Nullable<FloatArray>;
  21455. /**
  21456. * An array extending the number of possible indices
  21457. */
  21458. matricesIndicesExtra: Nullable<FloatArray>;
  21459. /**
  21460. * An array extending the number of possible weights when the number of indices is extended
  21461. */
  21462. matricesWeightsExtra: Nullable<FloatArray>;
  21463. /**
  21464. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21465. */
  21466. indices: Nullable<IndicesArray>;
  21467. /**
  21468. * Uses the passed data array to set the set the values for the specified kind of data
  21469. * @param data a linear array of floating numbers
  21470. * @param kind the type of data that is being set, eg positions, colors etc
  21471. */
  21472. set(data: FloatArray, kind: string): void;
  21473. /**
  21474. * Associates the vertexData to the passed Mesh.
  21475. * Sets it as updatable or not (default `false`)
  21476. * @param mesh the mesh the vertexData is applied to
  21477. * @param updatable when used and having the value true allows new data to update the vertexData
  21478. * @returns the VertexData
  21479. */
  21480. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21481. /**
  21482. * Associates the vertexData to the passed Geometry.
  21483. * Sets it as updatable or not (default `false`)
  21484. * @param geometry the geometry the vertexData is applied to
  21485. * @param updatable when used and having the value true allows new data to update the vertexData
  21486. * @returns VertexData
  21487. */
  21488. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21489. /**
  21490. * Updates the associated mesh
  21491. * @param mesh the mesh to be updated
  21492. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21493. * @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
  21494. * @returns VertexData
  21495. */
  21496. updateMesh(mesh: Mesh): VertexData;
  21497. /**
  21498. * Updates the associated geometry
  21499. * @param geometry the geometry to be updated
  21500. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21501. * @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
  21502. * @returns VertexData.
  21503. */
  21504. updateGeometry(geometry: Geometry): VertexData;
  21505. private _applyTo;
  21506. private _update;
  21507. /**
  21508. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21509. * @param matrix the transforming matrix
  21510. * @returns the VertexData
  21511. */
  21512. transform(matrix: Matrix): VertexData;
  21513. /**
  21514. * Merges the passed VertexData into the current one
  21515. * @param other the VertexData to be merged into the current one
  21516. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21517. * @returns the modified VertexData
  21518. */
  21519. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21520. private _mergeElement;
  21521. private _validate;
  21522. /**
  21523. * Serializes the VertexData
  21524. * @returns a serialized object
  21525. */
  21526. serialize(): any;
  21527. /**
  21528. * Extracts the vertexData from a mesh
  21529. * @param mesh the mesh from which to extract the VertexData
  21530. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21531. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21532. * @returns the object VertexData associated to the passed mesh
  21533. */
  21534. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21535. /**
  21536. * Extracts the vertexData from the geometry
  21537. * @param geometry the geometry from which to extract the VertexData
  21538. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21539. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21540. * @returns the object VertexData associated to the passed mesh
  21541. */
  21542. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21543. private static _ExtractFrom;
  21544. /**
  21545. * Creates the VertexData for a Ribbon
  21546. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21547. * * pathArray array of paths, each of which an array of successive Vector3
  21548. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21549. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21550. * * 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
  21551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21552. * * 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)
  21553. * * 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)
  21554. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21555. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21556. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21557. * @returns the VertexData of the ribbon
  21558. */
  21559. static CreateRibbon(options: {
  21560. pathArray: Vector3[][];
  21561. closeArray?: boolean;
  21562. closePath?: boolean;
  21563. offset?: number;
  21564. sideOrientation?: number;
  21565. frontUVs?: Vector4;
  21566. backUVs?: Vector4;
  21567. invertUV?: boolean;
  21568. uvs?: Vector2[];
  21569. colors?: Color4[];
  21570. }): VertexData;
  21571. /**
  21572. * Creates the VertexData for a box
  21573. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21574. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21575. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21576. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21577. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21578. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21579. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21581. * * 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)
  21582. * * 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)
  21583. * @returns the VertexData of the box
  21584. */
  21585. static CreateBox(options: {
  21586. size?: number;
  21587. width?: number;
  21588. height?: number;
  21589. depth?: number;
  21590. faceUV?: Vector4[];
  21591. faceColors?: Color4[];
  21592. sideOrientation?: number;
  21593. frontUVs?: Vector4;
  21594. backUVs?: Vector4;
  21595. }): VertexData;
  21596. /**
  21597. * Creates the VertexData for a tiled box
  21598. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21599. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21600. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21601. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21603. * @returns the VertexData of the box
  21604. */
  21605. static CreateTiledBox(options: {
  21606. pattern?: number;
  21607. width?: number;
  21608. height?: number;
  21609. depth?: number;
  21610. tileSize?: number;
  21611. tileWidth?: number;
  21612. tileHeight?: number;
  21613. alignHorizontal?: number;
  21614. alignVertical?: number;
  21615. faceUV?: Vector4[];
  21616. faceColors?: Color4[];
  21617. sideOrientation?: number;
  21618. }): VertexData;
  21619. /**
  21620. * Creates the VertexData for a tiled plane
  21621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21622. * * pattern a limited pattern arrangement depending on the number
  21623. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21624. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21625. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21627. * * 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)
  21628. * * 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)
  21629. * @returns the VertexData of the tiled plane
  21630. */
  21631. static CreateTiledPlane(options: {
  21632. pattern?: number;
  21633. tileSize?: number;
  21634. tileWidth?: number;
  21635. tileHeight?: number;
  21636. size?: number;
  21637. width?: number;
  21638. height?: number;
  21639. alignHorizontal?: number;
  21640. alignVertical?: number;
  21641. sideOrientation?: number;
  21642. frontUVs?: Vector4;
  21643. backUVs?: Vector4;
  21644. }): VertexData;
  21645. /**
  21646. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21647. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21648. * * segments sets the number of horizontal strips optional, default 32
  21649. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21650. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21651. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21652. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21653. * * 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
  21654. * * 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
  21655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21656. * * 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)
  21657. * * 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)
  21658. * @returns the VertexData of the ellipsoid
  21659. */
  21660. static CreateSphere(options: {
  21661. segments?: number;
  21662. diameter?: number;
  21663. diameterX?: number;
  21664. diameterY?: number;
  21665. diameterZ?: number;
  21666. arc?: number;
  21667. slice?: number;
  21668. sideOrientation?: number;
  21669. frontUVs?: Vector4;
  21670. backUVs?: Vector4;
  21671. }): VertexData;
  21672. /**
  21673. * Creates the VertexData for a cylinder, cone or prism
  21674. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21675. * * height sets the height (y direction) of the cylinder, optional, default 2
  21676. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21677. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21678. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21679. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21680. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21681. * * 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
  21682. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21683. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21684. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21685. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21687. * * 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)
  21688. * * 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)
  21689. * @returns the VertexData of the cylinder, cone or prism
  21690. */
  21691. static CreateCylinder(options: {
  21692. height?: number;
  21693. diameterTop?: number;
  21694. diameterBottom?: number;
  21695. diameter?: number;
  21696. tessellation?: number;
  21697. subdivisions?: number;
  21698. arc?: number;
  21699. faceColors?: Color4[];
  21700. faceUV?: Vector4[];
  21701. hasRings?: boolean;
  21702. enclose?: boolean;
  21703. sideOrientation?: number;
  21704. frontUVs?: Vector4;
  21705. backUVs?: Vector4;
  21706. }): VertexData;
  21707. /**
  21708. * Creates the VertexData for a torus
  21709. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21710. * * diameter the diameter of the torus, optional default 1
  21711. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21712. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21714. * * 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)
  21715. * * 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)
  21716. * @returns the VertexData of the torus
  21717. */
  21718. static CreateTorus(options: {
  21719. diameter?: number;
  21720. thickness?: number;
  21721. tessellation?: number;
  21722. sideOrientation?: number;
  21723. frontUVs?: Vector4;
  21724. backUVs?: Vector4;
  21725. }): VertexData;
  21726. /**
  21727. * Creates the VertexData of the LineSystem
  21728. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21729. * - lines an array of lines, each line being an array of successive Vector3
  21730. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21731. * @returns the VertexData of the LineSystem
  21732. */
  21733. static CreateLineSystem(options: {
  21734. lines: Vector3[][];
  21735. colors?: Nullable<Color4[][]>;
  21736. }): VertexData;
  21737. /**
  21738. * Create the VertexData for a DashedLines
  21739. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21740. * - points an array successive Vector3
  21741. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21742. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21743. * - dashNb the intended total number of dashes, optional, default 200
  21744. * @returns the VertexData for the DashedLines
  21745. */
  21746. static CreateDashedLines(options: {
  21747. points: Vector3[];
  21748. dashSize?: number;
  21749. gapSize?: number;
  21750. dashNb?: number;
  21751. }): VertexData;
  21752. /**
  21753. * Creates the VertexData for a Ground
  21754. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21755. * - width the width (x direction) of the ground, optional, default 1
  21756. * - height the height (z direction) of the ground, optional, default 1
  21757. * - subdivisions the number of subdivisions per side, optional, default 1
  21758. * @returns the VertexData of the Ground
  21759. */
  21760. static CreateGround(options: {
  21761. width?: number;
  21762. height?: number;
  21763. subdivisions?: number;
  21764. subdivisionsX?: number;
  21765. subdivisionsY?: number;
  21766. }): VertexData;
  21767. /**
  21768. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21769. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21770. * * xmin the ground minimum X coordinate, optional, default -1
  21771. * * zmin the ground minimum Z coordinate, optional, default -1
  21772. * * xmax the ground maximum X coordinate, optional, default 1
  21773. * * zmax the ground maximum Z coordinate, optional, default 1
  21774. * * 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}
  21775. * * 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}
  21776. * @returns the VertexData of the TiledGround
  21777. */
  21778. static CreateTiledGround(options: {
  21779. xmin: number;
  21780. zmin: number;
  21781. xmax: number;
  21782. zmax: number;
  21783. subdivisions?: {
  21784. w: number;
  21785. h: number;
  21786. };
  21787. precision?: {
  21788. w: number;
  21789. h: number;
  21790. };
  21791. }): VertexData;
  21792. /**
  21793. * Creates the VertexData of the Ground designed from a heightmap
  21794. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21795. * * width the width (x direction) of the ground
  21796. * * height the height (z direction) of the ground
  21797. * * subdivisions the number of subdivisions per side
  21798. * * minHeight the minimum altitude on the ground, optional, default 0
  21799. * * maxHeight the maximum altitude on the ground, optional default 1
  21800. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21801. * * buffer the array holding the image color data
  21802. * * bufferWidth the width of image
  21803. * * bufferHeight the height of image
  21804. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21805. * @returns the VertexData of the Ground designed from a heightmap
  21806. */
  21807. static CreateGroundFromHeightMap(options: {
  21808. width: number;
  21809. height: number;
  21810. subdivisions: number;
  21811. minHeight: number;
  21812. maxHeight: number;
  21813. colorFilter: Color3;
  21814. buffer: Uint8Array;
  21815. bufferWidth: number;
  21816. bufferHeight: number;
  21817. alphaFilter: number;
  21818. }): VertexData;
  21819. /**
  21820. * Creates the VertexData for a Plane
  21821. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21822. * * size sets the width and height of the plane to the value of size, optional default 1
  21823. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21824. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21826. * * 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)
  21827. * * 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)
  21828. * @returns the VertexData of the box
  21829. */
  21830. static CreatePlane(options: {
  21831. size?: number;
  21832. width?: number;
  21833. height?: number;
  21834. sideOrientation?: number;
  21835. frontUVs?: Vector4;
  21836. backUVs?: Vector4;
  21837. }): VertexData;
  21838. /**
  21839. * Creates the VertexData of the Disc or regular Polygon
  21840. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21841. * * radius the radius of the disc, optional default 0.5
  21842. * * tessellation the number of polygon sides, optional, default 64
  21843. * * 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
  21844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21845. * * 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)
  21846. * * 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)
  21847. * @returns the VertexData of the box
  21848. */
  21849. static CreateDisc(options: {
  21850. radius?: number;
  21851. tessellation?: number;
  21852. arc?: number;
  21853. sideOrientation?: number;
  21854. frontUVs?: Vector4;
  21855. backUVs?: Vector4;
  21856. }): VertexData;
  21857. /**
  21858. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21859. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21860. * @param polygon a mesh built from polygonTriangulation.build()
  21861. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21862. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21863. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21864. * @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)
  21865. * @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)
  21866. * @returns the VertexData of the Polygon
  21867. */
  21868. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21869. /**
  21870. * Creates the VertexData of the IcoSphere
  21871. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21872. * * radius the radius of the IcoSphere, optional default 1
  21873. * * radiusX allows stretching in the x direction, optional, default radius
  21874. * * radiusY allows stretching in the y direction, optional, default radius
  21875. * * radiusZ allows stretching in the z direction, optional, default radius
  21876. * * flat when true creates a flat shaded mesh, optional, default true
  21877. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21879. * * 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)
  21880. * * 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)
  21881. * @returns the VertexData of the IcoSphere
  21882. */
  21883. static CreateIcoSphere(options: {
  21884. radius?: number;
  21885. radiusX?: number;
  21886. radiusY?: number;
  21887. radiusZ?: number;
  21888. flat?: boolean;
  21889. subdivisions?: number;
  21890. sideOrientation?: number;
  21891. frontUVs?: Vector4;
  21892. backUVs?: Vector4;
  21893. }): VertexData;
  21894. /**
  21895. * Creates the VertexData for a Polyhedron
  21896. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21897. * * type provided types are:
  21898. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21899. * * 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)
  21900. * * size the size of the IcoSphere, optional default 1
  21901. * * sizeX allows stretching in the x direction, optional, default size
  21902. * * sizeY allows stretching in the y direction, optional, default size
  21903. * * sizeZ allows stretching in the z direction, optional, default size
  21904. * * 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
  21905. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21906. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21907. * * flat when true creates a flat shaded mesh, optional, default true
  21908. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21910. * * 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)
  21911. * * 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)
  21912. * @returns the VertexData of the Polyhedron
  21913. */
  21914. static CreatePolyhedron(options: {
  21915. type?: number;
  21916. size?: number;
  21917. sizeX?: number;
  21918. sizeY?: number;
  21919. sizeZ?: number;
  21920. custom?: any;
  21921. faceUV?: Vector4[];
  21922. faceColors?: Color4[];
  21923. flat?: boolean;
  21924. sideOrientation?: number;
  21925. frontUVs?: Vector4;
  21926. backUVs?: Vector4;
  21927. }): VertexData;
  21928. /**
  21929. * Creates the VertexData for a TorusKnot
  21930. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21931. * * radius the radius of the torus knot, optional, default 2
  21932. * * tube the thickness of the tube, optional, default 0.5
  21933. * * radialSegments the number of sides on each tube segments, optional, default 32
  21934. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21935. * * p the number of windings around the z axis, optional, default 2
  21936. * * q the number of windings around the x axis, optional, default 3
  21937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21938. * * 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)
  21939. * * 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)
  21940. * @returns the VertexData of the Torus Knot
  21941. */
  21942. static CreateTorusKnot(options: {
  21943. radius?: number;
  21944. tube?: number;
  21945. radialSegments?: number;
  21946. tubularSegments?: number;
  21947. p?: number;
  21948. q?: number;
  21949. sideOrientation?: number;
  21950. frontUVs?: Vector4;
  21951. backUVs?: Vector4;
  21952. }): VertexData;
  21953. /**
  21954. * Compute normals for given positions and indices
  21955. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21956. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21957. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21958. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21959. * * facetNormals : optional array of facet normals (vector3)
  21960. * * facetPositions : optional array of facet positions (vector3)
  21961. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21962. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21963. * * bInfo : optional bounding info, required for facetPartitioning computation
  21964. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21965. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21966. * * useRightHandedSystem: optional boolean to for right handed system computation
  21967. * * depthSort : optional boolean to enable the facet depth sort computation
  21968. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21969. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21970. */
  21971. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21972. facetNormals?: any;
  21973. facetPositions?: any;
  21974. facetPartitioning?: any;
  21975. ratio?: number;
  21976. bInfo?: any;
  21977. bbSize?: Vector3;
  21978. subDiv?: any;
  21979. useRightHandedSystem?: boolean;
  21980. depthSort?: boolean;
  21981. distanceTo?: Vector3;
  21982. depthSortedFacets?: any;
  21983. }): void;
  21984. /** @hidden */
  21985. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21986. /**
  21987. * Applies VertexData created from the imported parameters to the geometry
  21988. * @param parsedVertexData the parsed data from an imported file
  21989. * @param geometry the geometry to apply the VertexData to
  21990. */
  21991. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21992. }
  21993. }
  21994. declare module BABYLON {
  21995. /**
  21996. * Defines a target to use with MorphTargetManager
  21997. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21998. */
  21999. export class MorphTarget implements IAnimatable {
  22000. /** defines the name of the target */
  22001. name: string;
  22002. /**
  22003. * Gets or sets the list of animations
  22004. */
  22005. animations: Animation[];
  22006. private _scene;
  22007. private _positions;
  22008. private _normals;
  22009. private _tangents;
  22010. private _uvs;
  22011. private _influence;
  22012. /**
  22013. * Observable raised when the influence changes
  22014. */
  22015. onInfluenceChanged: Observable<boolean>;
  22016. /** @hidden */
  22017. _onDataLayoutChanged: Observable<void>;
  22018. /**
  22019. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22020. */
  22021. influence: number;
  22022. /**
  22023. * Gets or sets the id of the morph Target
  22024. */
  22025. id: string;
  22026. private _animationPropertiesOverride;
  22027. /**
  22028. * Gets or sets the animation properties override
  22029. */
  22030. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22031. /**
  22032. * Creates a new MorphTarget
  22033. * @param name defines the name of the target
  22034. * @param influence defines the influence to use
  22035. * @param scene defines the scene the morphtarget belongs to
  22036. */
  22037. constructor(
  22038. /** defines the name of the target */
  22039. name: string, influence?: number, scene?: Nullable<Scene>);
  22040. /**
  22041. * Gets a boolean defining if the target contains position data
  22042. */
  22043. readonly hasPositions: boolean;
  22044. /**
  22045. * Gets a boolean defining if the target contains normal data
  22046. */
  22047. readonly hasNormals: boolean;
  22048. /**
  22049. * Gets a boolean defining if the target contains tangent data
  22050. */
  22051. readonly hasTangents: boolean;
  22052. /**
  22053. * Gets a boolean defining if the target contains texture coordinates data
  22054. */
  22055. readonly hasUVs: boolean;
  22056. /**
  22057. * Affects position data to this target
  22058. * @param data defines the position data to use
  22059. */
  22060. setPositions(data: Nullable<FloatArray>): void;
  22061. /**
  22062. * Gets the position data stored in this target
  22063. * @returns a FloatArray containing the position data (or null if not present)
  22064. */
  22065. getPositions(): Nullable<FloatArray>;
  22066. /**
  22067. * Affects normal data to this target
  22068. * @param data defines the normal data to use
  22069. */
  22070. setNormals(data: Nullable<FloatArray>): void;
  22071. /**
  22072. * Gets the normal data stored in this target
  22073. * @returns a FloatArray containing the normal data (or null if not present)
  22074. */
  22075. getNormals(): Nullable<FloatArray>;
  22076. /**
  22077. * Affects tangent data to this target
  22078. * @param data defines the tangent data to use
  22079. */
  22080. setTangents(data: Nullable<FloatArray>): void;
  22081. /**
  22082. * Gets the tangent data stored in this target
  22083. * @returns a FloatArray containing the tangent data (or null if not present)
  22084. */
  22085. getTangents(): Nullable<FloatArray>;
  22086. /**
  22087. * Affects texture coordinates data to this target
  22088. * @param data defines the texture coordinates data to use
  22089. */
  22090. setUVs(data: Nullable<FloatArray>): void;
  22091. /**
  22092. * Gets the texture coordinates data stored in this target
  22093. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22094. */
  22095. getUVs(): Nullable<FloatArray>;
  22096. /**
  22097. * Serializes the current target into a Serialization object
  22098. * @returns the serialized object
  22099. */
  22100. serialize(): any;
  22101. /**
  22102. * Returns the string "MorphTarget"
  22103. * @returns "MorphTarget"
  22104. */
  22105. getClassName(): string;
  22106. /**
  22107. * Creates a new target from serialized data
  22108. * @param serializationObject defines the serialized data to use
  22109. * @returns a new MorphTarget
  22110. */
  22111. static Parse(serializationObject: any): MorphTarget;
  22112. /**
  22113. * Creates a MorphTarget from mesh data
  22114. * @param mesh defines the source mesh
  22115. * @param name defines the name to use for the new target
  22116. * @param influence defines the influence to attach to the target
  22117. * @returns a new MorphTarget
  22118. */
  22119. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22120. }
  22121. }
  22122. declare module BABYLON {
  22123. /**
  22124. * This class is used to deform meshes using morphing between different targets
  22125. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22126. */
  22127. export class MorphTargetManager {
  22128. private _targets;
  22129. private _targetInfluenceChangedObservers;
  22130. private _targetDataLayoutChangedObservers;
  22131. private _activeTargets;
  22132. private _scene;
  22133. private _influences;
  22134. private _supportsNormals;
  22135. private _supportsTangents;
  22136. private _supportsUVs;
  22137. private _vertexCount;
  22138. private _uniqueId;
  22139. private _tempInfluences;
  22140. /**
  22141. * Gets or sets a boolean indicating if normals must be morphed
  22142. */
  22143. enableNormalMorphing: boolean;
  22144. /**
  22145. * Gets or sets a boolean indicating if tangents must be morphed
  22146. */
  22147. enableTangentMorphing: boolean;
  22148. /**
  22149. * Gets or sets a boolean indicating if UV must be morphed
  22150. */
  22151. enableUVMorphing: boolean;
  22152. /**
  22153. * Creates a new MorphTargetManager
  22154. * @param scene defines the current scene
  22155. */
  22156. constructor(scene?: Nullable<Scene>);
  22157. /**
  22158. * Gets the unique ID of this manager
  22159. */
  22160. readonly uniqueId: number;
  22161. /**
  22162. * Gets the number of vertices handled by this manager
  22163. */
  22164. readonly vertexCount: number;
  22165. /**
  22166. * Gets a boolean indicating if this manager supports morphing of normals
  22167. */
  22168. readonly supportsNormals: boolean;
  22169. /**
  22170. * Gets a boolean indicating if this manager supports morphing of tangents
  22171. */
  22172. readonly supportsTangents: boolean;
  22173. /**
  22174. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22175. */
  22176. readonly supportsUVs: boolean;
  22177. /**
  22178. * Gets the number of targets stored in this manager
  22179. */
  22180. readonly numTargets: number;
  22181. /**
  22182. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22183. */
  22184. readonly numInfluencers: number;
  22185. /**
  22186. * Gets the list of influences (one per target)
  22187. */
  22188. readonly influences: Float32Array;
  22189. /**
  22190. * Gets the active target at specified index. An active target is a target with an influence > 0
  22191. * @param index defines the index to check
  22192. * @returns the requested target
  22193. */
  22194. getActiveTarget(index: number): MorphTarget;
  22195. /**
  22196. * Gets the target at specified index
  22197. * @param index defines the index to check
  22198. * @returns the requested target
  22199. */
  22200. getTarget(index: number): MorphTarget;
  22201. /**
  22202. * Add a new target to this manager
  22203. * @param target defines the target to add
  22204. */
  22205. addTarget(target: MorphTarget): void;
  22206. /**
  22207. * Removes a target from the manager
  22208. * @param target defines the target to remove
  22209. */
  22210. removeTarget(target: MorphTarget): void;
  22211. /**
  22212. * Serializes the current manager into a Serialization object
  22213. * @returns the serialized object
  22214. */
  22215. serialize(): any;
  22216. private _syncActiveTargets;
  22217. /**
  22218. * Syncrhonize the targets with all the meshes using this morph target manager
  22219. */
  22220. synchronize(): void;
  22221. /**
  22222. * Creates a new MorphTargetManager from serialized data
  22223. * @param serializationObject defines the serialized data
  22224. * @param scene defines the hosting scene
  22225. * @returns the new MorphTargetManager
  22226. */
  22227. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22228. }
  22229. }
  22230. declare module BABYLON {
  22231. /**
  22232. * Class used to represent a specific level of detail of a mesh
  22233. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22234. */
  22235. export class MeshLODLevel {
  22236. /** Defines the distance where this level should start being displayed */
  22237. distance: number;
  22238. /** Defines the mesh to use to render this level */
  22239. mesh: Nullable<Mesh>;
  22240. /**
  22241. * Creates a new LOD level
  22242. * @param distance defines the distance where this level should star being displayed
  22243. * @param mesh defines the mesh to use to render this level
  22244. */
  22245. constructor(
  22246. /** Defines the distance where this level should start being displayed */
  22247. distance: number,
  22248. /** Defines the mesh to use to render this level */
  22249. mesh: Nullable<Mesh>);
  22250. }
  22251. }
  22252. declare module BABYLON {
  22253. /**
  22254. * Mesh representing the gorund
  22255. */
  22256. export class GroundMesh extends Mesh {
  22257. /** If octree should be generated */
  22258. generateOctree: boolean;
  22259. private _heightQuads;
  22260. /** @hidden */
  22261. _subdivisionsX: number;
  22262. /** @hidden */
  22263. _subdivisionsY: number;
  22264. /** @hidden */
  22265. _width: number;
  22266. /** @hidden */
  22267. _height: number;
  22268. /** @hidden */
  22269. _minX: number;
  22270. /** @hidden */
  22271. _maxX: number;
  22272. /** @hidden */
  22273. _minZ: number;
  22274. /** @hidden */
  22275. _maxZ: number;
  22276. constructor(name: string, scene: Scene);
  22277. /**
  22278. * "GroundMesh"
  22279. * @returns "GroundMesh"
  22280. */
  22281. getClassName(): string;
  22282. /**
  22283. * The minimum of x and y subdivisions
  22284. */
  22285. readonly subdivisions: number;
  22286. /**
  22287. * X subdivisions
  22288. */
  22289. readonly subdivisionsX: number;
  22290. /**
  22291. * Y subdivisions
  22292. */
  22293. readonly subdivisionsY: number;
  22294. /**
  22295. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22296. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22297. * @param chunksCount the number of subdivisions for x and y
  22298. * @param octreeBlocksSize (Default: 32)
  22299. */
  22300. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22301. /**
  22302. * Returns a height (y) value in the Worl system :
  22303. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22304. * @param x x coordinate
  22305. * @param z z coordinate
  22306. * @returns the ground y position if (x, z) are outside the ground surface.
  22307. */
  22308. getHeightAtCoordinates(x: number, z: number): number;
  22309. /**
  22310. * Returns a normalized vector (Vector3) orthogonal to the ground
  22311. * at the ground coordinates (x, z) expressed in the World system.
  22312. * @param x x coordinate
  22313. * @param z z coordinate
  22314. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22315. */
  22316. getNormalAtCoordinates(x: number, z: number): Vector3;
  22317. /**
  22318. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22319. * at the ground coordinates (x, z) expressed in the World system.
  22320. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22321. * @param x x coordinate
  22322. * @param z z coordinate
  22323. * @param ref vector to store the result
  22324. * @returns the GroundMesh.
  22325. */
  22326. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22327. /**
  22328. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22329. * if the ground has been updated.
  22330. * This can be used in the render loop.
  22331. * @returns the GroundMesh.
  22332. */
  22333. updateCoordinateHeights(): GroundMesh;
  22334. private _getFacetAt;
  22335. private _initHeightQuads;
  22336. private _computeHeightQuads;
  22337. /**
  22338. * Serializes this ground mesh
  22339. * @param serializationObject object to write serialization to
  22340. */
  22341. serialize(serializationObject: any): void;
  22342. /**
  22343. * Parses a serialized ground mesh
  22344. * @param parsedMesh the serialized mesh
  22345. * @param scene the scene to create the ground mesh in
  22346. * @returns the created ground mesh
  22347. */
  22348. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22349. }
  22350. }
  22351. declare module BABYLON {
  22352. /**
  22353. * Interface for Physics-Joint data
  22354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22355. */
  22356. export interface PhysicsJointData {
  22357. /**
  22358. * The main pivot of the joint
  22359. */
  22360. mainPivot?: Vector3;
  22361. /**
  22362. * The connected pivot of the joint
  22363. */
  22364. connectedPivot?: Vector3;
  22365. /**
  22366. * The main axis of the joint
  22367. */
  22368. mainAxis?: Vector3;
  22369. /**
  22370. * The connected axis of the joint
  22371. */
  22372. connectedAxis?: Vector3;
  22373. /**
  22374. * The collision of the joint
  22375. */
  22376. collision?: boolean;
  22377. /**
  22378. * Native Oimo/Cannon/Energy data
  22379. */
  22380. nativeParams?: any;
  22381. }
  22382. /**
  22383. * This is a holder class for the physics joint created by the physics plugin
  22384. * It holds a set of functions to control the underlying joint
  22385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22386. */
  22387. export class PhysicsJoint {
  22388. /**
  22389. * The type of the physics joint
  22390. */
  22391. type: number;
  22392. /**
  22393. * The data for the physics joint
  22394. */
  22395. jointData: PhysicsJointData;
  22396. private _physicsJoint;
  22397. protected _physicsPlugin: IPhysicsEnginePlugin;
  22398. /**
  22399. * Initializes the physics joint
  22400. * @param type The type of the physics joint
  22401. * @param jointData The data for the physics joint
  22402. */
  22403. constructor(
  22404. /**
  22405. * The type of the physics joint
  22406. */
  22407. type: number,
  22408. /**
  22409. * The data for the physics joint
  22410. */
  22411. jointData: PhysicsJointData);
  22412. /**
  22413. * Gets the physics joint
  22414. */
  22415. /**
  22416. * Sets the physics joint
  22417. */
  22418. physicsJoint: any;
  22419. /**
  22420. * Sets the physics plugin
  22421. */
  22422. physicsPlugin: IPhysicsEnginePlugin;
  22423. /**
  22424. * Execute a function that is physics-plugin specific.
  22425. * @param {Function} func the function that will be executed.
  22426. * It accepts two parameters: the physics world and the physics joint
  22427. */
  22428. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22429. /**
  22430. * Distance-Joint type
  22431. */
  22432. static DistanceJoint: number;
  22433. /**
  22434. * Hinge-Joint type
  22435. */
  22436. static HingeJoint: number;
  22437. /**
  22438. * Ball-and-Socket joint type
  22439. */
  22440. static BallAndSocketJoint: number;
  22441. /**
  22442. * Wheel-Joint type
  22443. */
  22444. static WheelJoint: number;
  22445. /**
  22446. * Slider-Joint type
  22447. */
  22448. static SliderJoint: number;
  22449. /**
  22450. * Prismatic-Joint type
  22451. */
  22452. static PrismaticJoint: number;
  22453. /**
  22454. * Universal-Joint type
  22455. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22456. */
  22457. static UniversalJoint: number;
  22458. /**
  22459. * Hinge-Joint 2 type
  22460. */
  22461. static Hinge2Joint: number;
  22462. /**
  22463. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22464. */
  22465. static PointToPointJoint: number;
  22466. /**
  22467. * Spring-Joint type
  22468. */
  22469. static SpringJoint: number;
  22470. /**
  22471. * Lock-Joint type
  22472. */
  22473. static LockJoint: number;
  22474. }
  22475. /**
  22476. * A class representing a physics distance joint
  22477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22478. */
  22479. export class DistanceJoint extends PhysicsJoint {
  22480. /**
  22481. *
  22482. * @param jointData The data for the Distance-Joint
  22483. */
  22484. constructor(jointData: DistanceJointData);
  22485. /**
  22486. * Update the predefined distance.
  22487. * @param maxDistance The maximum preferred distance
  22488. * @param minDistance The minimum preferred distance
  22489. */
  22490. updateDistance(maxDistance: number, minDistance?: number): void;
  22491. }
  22492. /**
  22493. * Represents a Motor-Enabled Joint
  22494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22495. */
  22496. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22497. /**
  22498. * Initializes the Motor-Enabled Joint
  22499. * @param type The type of the joint
  22500. * @param jointData The physica joint data for the joint
  22501. */
  22502. constructor(type: number, jointData: PhysicsJointData);
  22503. /**
  22504. * Set the motor values.
  22505. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22506. * @param force the force to apply
  22507. * @param maxForce max force for this motor.
  22508. */
  22509. setMotor(force?: number, maxForce?: number): void;
  22510. /**
  22511. * Set the motor's limits.
  22512. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22513. * @param upperLimit The upper limit of the motor
  22514. * @param lowerLimit The lower limit of the motor
  22515. */
  22516. setLimit(upperLimit: number, lowerLimit?: number): void;
  22517. }
  22518. /**
  22519. * This class represents a single physics Hinge-Joint
  22520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22521. */
  22522. export class HingeJoint extends MotorEnabledJoint {
  22523. /**
  22524. * Initializes the Hinge-Joint
  22525. * @param jointData The joint data for the Hinge-Joint
  22526. */
  22527. constructor(jointData: PhysicsJointData);
  22528. /**
  22529. * Set the motor values.
  22530. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22531. * @param {number} force the force to apply
  22532. * @param {number} maxForce max force for this motor.
  22533. */
  22534. setMotor(force?: number, maxForce?: number): void;
  22535. /**
  22536. * Set the motor's limits.
  22537. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22538. * @param upperLimit The upper limit of the motor
  22539. * @param lowerLimit The lower limit of the motor
  22540. */
  22541. setLimit(upperLimit: number, lowerLimit?: number): void;
  22542. }
  22543. /**
  22544. * This class represents a dual hinge physics joint (same as wheel joint)
  22545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22546. */
  22547. export class Hinge2Joint extends MotorEnabledJoint {
  22548. /**
  22549. * Initializes the Hinge2-Joint
  22550. * @param jointData The joint data for the Hinge2-Joint
  22551. */
  22552. constructor(jointData: PhysicsJointData);
  22553. /**
  22554. * Set the motor values.
  22555. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22556. * @param {number} targetSpeed the speed the motor is to reach
  22557. * @param {number} maxForce max force for this motor.
  22558. * @param {motorIndex} the motor's index, 0 or 1.
  22559. */
  22560. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22561. /**
  22562. * Set the motor limits.
  22563. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22564. * @param {number} upperLimit the upper limit
  22565. * @param {number} lowerLimit lower limit
  22566. * @param {motorIndex} the motor's index, 0 or 1.
  22567. */
  22568. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22569. }
  22570. /**
  22571. * Interface for a motor enabled joint
  22572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22573. */
  22574. export interface IMotorEnabledJoint {
  22575. /**
  22576. * Physics joint
  22577. */
  22578. physicsJoint: any;
  22579. /**
  22580. * Sets the motor of the motor-enabled joint
  22581. * @param force The force of the motor
  22582. * @param maxForce The maximum force of the motor
  22583. * @param motorIndex The index of the motor
  22584. */
  22585. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22586. /**
  22587. * Sets the limit of the motor
  22588. * @param upperLimit The upper limit of the motor
  22589. * @param lowerLimit The lower limit of the motor
  22590. * @param motorIndex The index of the motor
  22591. */
  22592. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22593. }
  22594. /**
  22595. * Joint data for a Distance-Joint
  22596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22597. */
  22598. export interface DistanceJointData extends PhysicsJointData {
  22599. /**
  22600. * Max distance the 2 joint objects can be apart
  22601. */
  22602. maxDistance: number;
  22603. }
  22604. /**
  22605. * Joint data from a spring joint
  22606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22607. */
  22608. export interface SpringJointData extends PhysicsJointData {
  22609. /**
  22610. * Length of the spring
  22611. */
  22612. length: number;
  22613. /**
  22614. * Stiffness of the spring
  22615. */
  22616. stiffness: number;
  22617. /**
  22618. * Damping of the spring
  22619. */
  22620. damping: number;
  22621. /** this callback will be called when applying the force to the impostors. */
  22622. forceApplicationCallback: () => void;
  22623. }
  22624. }
  22625. declare module BABYLON {
  22626. /**
  22627. * Holds the data for the raycast result
  22628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22629. */
  22630. export class PhysicsRaycastResult {
  22631. private _hasHit;
  22632. private _hitDistance;
  22633. private _hitNormalWorld;
  22634. private _hitPointWorld;
  22635. private _rayFromWorld;
  22636. private _rayToWorld;
  22637. /**
  22638. * Gets if there was a hit
  22639. */
  22640. readonly hasHit: boolean;
  22641. /**
  22642. * Gets the distance from the hit
  22643. */
  22644. readonly hitDistance: number;
  22645. /**
  22646. * Gets the hit normal/direction in the world
  22647. */
  22648. readonly hitNormalWorld: Vector3;
  22649. /**
  22650. * Gets the hit point in the world
  22651. */
  22652. readonly hitPointWorld: Vector3;
  22653. /**
  22654. * Gets the ray "start point" of the ray in the world
  22655. */
  22656. readonly rayFromWorld: Vector3;
  22657. /**
  22658. * Gets the ray "end point" of the ray in the world
  22659. */
  22660. readonly rayToWorld: Vector3;
  22661. /**
  22662. * Sets the hit data (normal & point in world space)
  22663. * @param hitNormalWorld defines the normal in world space
  22664. * @param hitPointWorld defines the point in world space
  22665. */
  22666. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22667. /**
  22668. * Sets the distance from the start point to the hit point
  22669. * @param distance
  22670. */
  22671. setHitDistance(distance: number): void;
  22672. /**
  22673. * Calculates the distance manually
  22674. */
  22675. calculateHitDistance(): void;
  22676. /**
  22677. * Resets all the values to default
  22678. * @param from The from point on world space
  22679. * @param to The to point on world space
  22680. */
  22681. reset(from?: Vector3, to?: Vector3): void;
  22682. }
  22683. /**
  22684. * Interface for the size containing width and height
  22685. */
  22686. interface IXYZ {
  22687. /**
  22688. * X
  22689. */
  22690. x: number;
  22691. /**
  22692. * Y
  22693. */
  22694. y: number;
  22695. /**
  22696. * Z
  22697. */
  22698. z: number;
  22699. }
  22700. }
  22701. declare module BABYLON {
  22702. /**
  22703. * Interface used to describe a physics joint
  22704. */
  22705. export interface PhysicsImpostorJoint {
  22706. /** Defines the main impostor to which the joint is linked */
  22707. mainImpostor: PhysicsImpostor;
  22708. /** Defines the impostor that is connected to the main impostor using this joint */
  22709. connectedImpostor: PhysicsImpostor;
  22710. /** Defines the joint itself */
  22711. joint: PhysicsJoint;
  22712. }
  22713. /** @hidden */
  22714. export interface IPhysicsEnginePlugin {
  22715. world: any;
  22716. name: string;
  22717. setGravity(gravity: Vector3): void;
  22718. setTimeStep(timeStep: number): void;
  22719. getTimeStep(): number;
  22720. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22721. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22722. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22724. removePhysicsBody(impostor: PhysicsImpostor): void;
  22725. generateJoint(joint: PhysicsImpostorJoint): void;
  22726. removeJoint(joint: PhysicsImpostorJoint): void;
  22727. isSupported(): boolean;
  22728. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22729. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22730. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22731. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22732. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22733. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22734. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22735. getBodyMass(impostor: PhysicsImpostor): number;
  22736. getBodyFriction(impostor: PhysicsImpostor): number;
  22737. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22738. getBodyRestitution(impostor: PhysicsImpostor): number;
  22739. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22740. getBodyPressure?(impostor: PhysicsImpostor): number;
  22741. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22742. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22743. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22744. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22745. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22746. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22747. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22748. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22749. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22750. sleepBody(impostor: PhysicsImpostor): void;
  22751. wakeUpBody(impostor: PhysicsImpostor): void;
  22752. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22753. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22754. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22755. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22756. getRadius(impostor: PhysicsImpostor): number;
  22757. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22758. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22759. dispose(): void;
  22760. }
  22761. /**
  22762. * Interface used to define a physics engine
  22763. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22764. */
  22765. export interface IPhysicsEngine {
  22766. /**
  22767. * Gets the gravity vector used by the simulation
  22768. */
  22769. gravity: Vector3;
  22770. /**
  22771. * Sets the gravity vector used by the simulation
  22772. * @param gravity defines the gravity vector to use
  22773. */
  22774. setGravity(gravity: Vector3): void;
  22775. /**
  22776. * Set the time step of the physics engine.
  22777. * Default is 1/60.
  22778. * To slow it down, enter 1/600 for example.
  22779. * To speed it up, 1/30
  22780. * @param newTimeStep the new timestep to apply to this world.
  22781. */
  22782. setTimeStep(newTimeStep: number): void;
  22783. /**
  22784. * Get the time step of the physics engine.
  22785. * @returns the current time step
  22786. */
  22787. getTimeStep(): number;
  22788. /**
  22789. * Release all resources
  22790. */
  22791. dispose(): void;
  22792. /**
  22793. * Gets the name of the current physics plugin
  22794. * @returns the name of the plugin
  22795. */
  22796. getPhysicsPluginName(): string;
  22797. /**
  22798. * Adding a new impostor for the impostor tracking.
  22799. * This will be done by the impostor itself.
  22800. * @param impostor the impostor to add
  22801. */
  22802. addImpostor(impostor: PhysicsImpostor): void;
  22803. /**
  22804. * Remove an impostor from the engine.
  22805. * This impostor and its mesh will not longer be updated by the physics engine.
  22806. * @param impostor the impostor to remove
  22807. */
  22808. removeImpostor(impostor: PhysicsImpostor): void;
  22809. /**
  22810. * Add a joint to the physics engine
  22811. * @param mainImpostor defines the main impostor to which the joint is added.
  22812. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22813. * @param joint defines the joint that will connect both impostors.
  22814. */
  22815. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22816. /**
  22817. * Removes a joint from the simulation
  22818. * @param mainImpostor defines the impostor used with the joint
  22819. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22820. * @param joint defines the joint to remove
  22821. */
  22822. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22823. /**
  22824. * Gets the current plugin used to run the simulation
  22825. * @returns current plugin
  22826. */
  22827. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22828. /**
  22829. * Gets the list of physic impostors
  22830. * @returns an array of PhysicsImpostor
  22831. */
  22832. getImpostors(): Array<PhysicsImpostor>;
  22833. /**
  22834. * Gets the impostor for a physics enabled object
  22835. * @param object defines the object impersonated by the impostor
  22836. * @returns the PhysicsImpostor or null if not found
  22837. */
  22838. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22839. /**
  22840. * Gets the impostor for a physics body object
  22841. * @param body defines physics body used by the impostor
  22842. * @returns the PhysicsImpostor or null if not found
  22843. */
  22844. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22845. /**
  22846. * Does a raycast in the physics world
  22847. * @param from when should the ray start?
  22848. * @param to when should the ray end?
  22849. * @returns PhysicsRaycastResult
  22850. */
  22851. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22852. /**
  22853. * Called by the scene. No need to call it.
  22854. * @param delta defines the timespam between frames
  22855. */
  22856. _step(delta: number): void;
  22857. }
  22858. }
  22859. declare module BABYLON {
  22860. /**
  22861. * The interface for the physics imposter parameters
  22862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22863. */
  22864. export interface PhysicsImpostorParameters {
  22865. /**
  22866. * The mass of the physics imposter
  22867. */
  22868. mass: number;
  22869. /**
  22870. * The friction of the physics imposter
  22871. */
  22872. friction?: number;
  22873. /**
  22874. * The coefficient of restitution of the physics imposter
  22875. */
  22876. restitution?: number;
  22877. /**
  22878. * The native options of the physics imposter
  22879. */
  22880. nativeOptions?: any;
  22881. /**
  22882. * Specifies if the parent should be ignored
  22883. */
  22884. ignoreParent?: boolean;
  22885. /**
  22886. * Specifies if bi-directional transformations should be disabled
  22887. */
  22888. disableBidirectionalTransformation?: boolean;
  22889. /**
  22890. * The pressure inside the physics imposter, soft object only
  22891. */
  22892. pressure?: number;
  22893. /**
  22894. * The stiffness the physics imposter, soft object only
  22895. */
  22896. stiffness?: number;
  22897. /**
  22898. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22899. */
  22900. velocityIterations?: number;
  22901. /**
  22902. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22903. */
  22904. positionIterations?: number;
  22905. /**
  22906. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22907. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22908. * Add to fix multiple points
  22909. */
  22910. fixedPoints?: number;
  22911. /**
  22912. * The collision margin around a soft object
  22913. */
  22914. margin?: number;
  22915. /**
  22916. * The collision margin around a soft object
  22917. */
  22918. damping?: number;
  22919. /**
  22920. * The path for a rope based on an extrusion
  22921. */
  22922. path?: any;
  22923. /**
  22924. * The shape of an extrusion used for a rope based on an extrusion
  22925. */
  22926. shape?: any;
  22927. }
  22928. /**
  22929. * Interface for a physics-enabled object
  22930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22931. */
  22932. export interface IPhysicsEnabledObject {
  22933. /**
  22934. * The position of the physics-enabled object
  22935. */
  22936. position: Vector3;
  22937. /**
  22938. * The rotation of the physics-enabled object
  22939. */
  22940. rotationQuaternion: Nullable<Quaternion>;
  22941. /**
  22942. * The scale of the physics-enabled object
  22943. */
  22944. scaling: Vector3;
  22945. /**
  22946. * The rotation of the physics-enabled object
  22947. */
  22948. rotation?: Vector3;
  22949. /**
  22950. * The parent of the physics-enabled object
  22951. */
  22952. parent?: any;
  22953. /**
  22954. * The bounding info of the physics-enabled object
  22955. * @returns The bounding info of the physics-enabled object
  22956. */
  22957. getBoundingInfo(): BoundingInfo;
  22958. /**
  22959. * Computes the world matrix
  22960. * @param force Specifies if the world matrix should be computed by force
  22961. * @returns A world matrix
  22962. */
  22963. computeWorldMatrix(force: boolean): Matrix;
  22964. /**
  22965. * Gets the world matrix
  22966. * @returns A world matrix
  22967. */
  22968. getWorldMatrix?(): Matrix;
  22969. /**
  22970. * Gets the child meshes
  22971. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22972. * @returns An array of abstract meshes
  22973. */
  22974. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22975. /**
  22976. * Gets the vertex data
  22977. * @param kind The type of vertex data
  22978. * @returns A nullable array of numbers, or a float32 array
  22979. */
  22980. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22981. /**
  22982. * Gets the indices from the mesh
  22983. * @returns A nullable array of index arrays
  22984. */
  22985. getIndices?(): Nullable<IndicesArray>;
  22986. /**
  22987. * Gets the scene from the mesh
  22988. * @returns the indices array or null
  22989. */
  22990. getScene?(): Scene;
  22991. /**
  22992. * Gets the absolute position from the mesh
  22993. * @returns the absolute position
  22994. */
  22995. getAbsolutePosition(): Vector3;
  22996. /**
  22997. * Gets the absolute pivot point from the mesh
  22998. * @returns the absolute pivot point
  22999. */
  23000. getAbsolutePivotPoint(): Vector3;
  23001. /**
  23002. * Rotates the mesh
  23003. * @param axis The axis of rotation
  23004. * @param amount The amount of rotation
  23005. * @param space The space of the rotation
  23006. * @returns The rotation transform node
  23007. */
  23008. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23009. /**
  23010. * Translates the mesh
  23011. * @param axis The axis of translation
  23012. * @param distance The distance of translation
  23013. * @param space The space of the translation
  23014. * @returns The transform node
  23015. */
  23016. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23017. /**
  23018. * Sets the absolute position of the mesh
  23019. * @param absolutePosition The absolute position of the mesh
  23020. * @returns The transform node
  23021. */
  23022. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23023. /**
  23024. * Gets the class name of the mesh
  23025. * @returns The class name
  23026. */
  23027. getClassName(): string;
  23028. }
  23029. /**
  23030. * Represents a physics imposter
  23031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23032. */
  23033. export class PhysicsImpostor {
  23034. /**
  23035. * The physics-enabled object used as the physics imposter
  23036. */
  23037. object: IPhysicsEnabledObject;
  23038. /**
  23039. * The type of the physics imposter
  23040. */
  23041. type: number;
  23042. private _options;
  23043. private _scene?;
  23044. /**
  23045. * The default object size of the imposter
  23046. */
  23047. static DEFAULT_OBJECT_SIZE: Vector3;
  23048. /**
  23049. * The identity quaternion of the imposter
  23050. */
  23051. static IDENTITY_QUATERNION: Quaternion;
  23052. /** @hidden */
  23053. _pluginData: any;
  23054. private _physicsEngine;
  23055. private _physicsBody;
  23056. private _bodyUpdateRequired;
  23057. private _onBeforePhysicsStepCallbacks;
  23058. private _onAfterPhysicsStepCallbacks;
  23059. /** @hidden */
  23060. _onPhysicsCollideCallbacks: Array<{
  23061. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23062. otherImpostors: Array<PhysicsImpostor>;
  23063. }>;
  23064. private _deltaPosition;
  23065. private _deltaRotation;
  23066. private _deltaRotationConjugated;
  23067. /** @hidden */
  23068. _isFromLine: boolean;
  23069. private _parent;
  23070. private _isDisposed;
  23071. private static _tmpVecs;
  23072. private static _tmpQuat;
  23073. /**
  23074. * Specifies if the physics imposter is disposed
  23075. */
  23076. readonly isDisposed: boolean;
  23077. /**
  23078. * Gets the mass of the physics imposter
  23079. */
  23080. mass: number;
  23081. /**
  23082. * Gets the coefficient of friction
  23083. */
  23084. /**
  23085. * Sets the coefficient of friction
  23086. */
  23087. friction: number;
  23088. /**
  23089. * Gets the coefficient of restitution
  23090. */
  23091. /**
  23092. * Sets the coefficient of restitution
  23093. */
  23094. restitution: number;
  23095. /**
  23096. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23097. */
  23098. /**
  23099. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23100. */
  23101. pressure: number;
  23102. /**
  23103. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23104. */
  23105. /**
  23106. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23107. */
  23108. stiffness: number;
  23109. /**
  23110. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23111. */
  23112. /**
  23113. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23114. */
  23115. velocityIterations: number;
  23116. /**
  23117. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23118. */
  23119. /**
  23120. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23121. */
  23122. positionIterations: number;
  23123. /**
  23124. * The unique id of the physics imposter
  23125. * set by the physics engine when adding this impostor to the array
  23126. */
  23127. uniqueId: number;
  23128. /**
  23129. * @hidden
  23130. */
  23131. soft: boolean;
  23132. /**
  23133. * @hidden
  23134. */
  23135. segments: number;
  23136. private _joints;
  23137. /**
  23138. * Initializes the physics imposter
  23139. * @param object The physics-enabled object used as the physics imposter
  23140. * @param type The type of the physics imposter
  23141. * @param _options The options for the physics imposter
  23142. * @param _scene The Babylon scene
  23143. */
  23144. constructor(
  23145. /**
  23146. * The physics-enabled object used as the physics imposter
  23147. */
  23148. object: IPhysicsEnabledObject,
  23149. /**
  23150. * The type of the physics imposter
  23151. */
  23152. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23153. /**
  23154. * This function will completly initialize this impostor.
  23155. * It will create a new body - but only if this mesh has no parent.
  23156. * If it has, this impostor will not be used other than to define the impostor
  23157. * of the child mesh.
  23158. * @hidden
  23159. */
  23160. _init(): void;
  23161. private _getPhysicsParent;
  23162. /**
  23163. * Should a new body be generated.
  23164. * @returns boolean specifying if body initialization is required
  23165. */
  23166. isBodyInitRequired(): boolean;
  23167. /**
  23168. * Sets the updated scaling
  23169. * @param updated Specifies if the scaling is updated
  23170. */
  23171. setScalingUpdated(): void;
  23172. /**
  23173. * Force a regeneration of this or the parent's impostor's body.
  23174. * Use under cautious - This will remove all joints already implemented.
  23175. */
  23176. forceUpdate(): void;
  23177. /**
  23178. * Gets the body that holds this impostor. Either its own, or its parent.
  23179. */
  23180. /**
  23181. * Set the physics body. Used mainly by the physics engine/plugin
  23182. */
  23183. physicsBody: any;
  23184. /**
  23185. * Get the parent of the physics imposter
  23186. * @returns Physics imposter or null
  23187. */
  23188. /**
  23189. * Sets the parent of the physics imposter
  23190. */
  23191. parent: Nullable<PhysicsImpostor>;
  23192. /**
  23193. * Resets the update flags
  23194. */
  23195. resetUpdateFlags(): void;
  23196. /**
  23197. * Gets the object extend size
  23198. * @returns the object extend size
  23199. */
  23200. getObjectExtendSize(): Vector3;
  23201. /**
  23202. * Gets the object center
  23203. * @returns The object center
  23204. */
  23205. getObjectCenter(): Vector3;
  23206. /**
  23207. * Get a specific parametes from the options parameter
  23208. * @param paramName The object parameter name
  23209. * @returns The object parameter
  23210. */
  23211. getParam(paramName: string): any;
  23212. /**
  23213. * Sets a specific parameter in the options given to the physics plugin
  23214. * @param paramName The parameter name
  23215. * @param value The value of the parameter
  23216. */
  23217. setParam(paramName: string, value: number): void;
  23218. /**
  23219. * Specifically change the body's mass option. Won't recreate the physics body object
  23220. * @param mass The mass of the physics imposter
  23221. */
  23222. setMass(mass: number): void;
  23223. /**
  23224. * Gets the linear velocity
  23225. * @returns linear velocity or null
  23226. */
  23227. getLinearVelocity(): Nullable<Vector3>;
  23228. /**
  23229. * Sets the linear velocity
  23230. * @param velocity linear velocity or null
  23231. */
  23232. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23233. /**
  23234. * Gets the angular velocity
  23235. * @returns angular velocity or null
  23236. */
  23237. getAngularVelocity(): Nullable<Vector3>;
  23238. /**
  23239. * Sets the angular velocity
  23240. * @param velocity The velocity or null
  23241. */
  23242. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23243. /**
  23244. * Execute a function with the physics plugin native code
  23245. * Provide a function the will have two variables - the world object and the physics body object
  23246. * @param func The function to execute with the physics plugin native code
  23247. */
  23248. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23249. /**
  23250. * Register a function that will be executed before the physics world is stepping forward
  23251. * @param func The function to execute before the physics world is stepped forward
  23252. */
  23253. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23254. /**
  23255. * Unregister a function that will be executed before the physics world is stepping forward
  23256. * @param func The function to execute before the physics world is stepped forward
  23257. */
  23258. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23259. /**
  23260. * Register a function that will be executed after the physics step
  23261. * @param func The function to execute after physics step
  23262. */
  23263. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23264. /**
  23265. * Unregisters a function that will be executed after the physics step
  23266. * @param func The function to execute after physics step
  23267. */
  23268. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23269. /**
  23270. * register a function that will be executed when this impostor collides against a different body
  23271. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23272. * @param func Callback that is executed on collision
  23273. */
  23274. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23275. /**
  23276. * Unregisters the physics imposter on contact
  23277. * @param collideAgainst The physics object to collide against
  23278. * @param func Callback to execute on collision
  23279. */
  23280. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23281. private _tmpQuat;
  23282. private _tmpQuat2;
  23283. /**
  23284. * Get the parent rotation
  23285. * @returns The parent rotation
  23286. */
  23287. getParentsRotation(): Quaternion;
  23288. /**
  23289. * this function is executed by the physics engine.
  23290. */
  23291. beforeStep: () => void;
  23292. /**
  23293. * this function is executed by the physics engine
  23294. */
  23295. afterStep: () => void;
  23296. /**
  23297. * Legacy collision detection event support
  23298. */
  23299. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23300. /**
  23301. * event and body object due to cannon's event-based architecture.
  23302. */
  23303. onCollide: (e: {
  23304. body: any;
  23305. }) => void;
  23306. /**
  23307. * Apply a force
  23308. * @param force The force to apply
  23309. * @param contactPoint The contact point for the force
  23310. * @returns The physics imposter
  23311. */
  23312. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23313. /**
  23314. * Apply an impulse
  23315. * @param force The impulse force
  23316. * @param contactPoint The contact point for the impulse force
  23317. * @returns The physics imposter
  23318. */
  23319. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23320. /**
  23321. * A help function to create a joint
  23322. * @param otherImpostor A physics imposter used to create a joint
  23323. * @param jointType The type of joint
  23324. * @param jointData The data for the joint
  23325. * @returns The physics imposter
  23326. */
  23327. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23328. /**
  23329. * Add a joint to this impostor with a different impostor
  23330. * @param otherImpostor A physics imposter used to add a joint
  23331. * @param joint The joint to add
  23332. * @returns The physics imposter
  23333. */
  23334. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23335. /**
  23336. * Add an anchor to a cloth impostor
  23337. * @param otherImpostor rigid impostor to anchor to
  23338. * @param width ratio across width from 0 to 1
  23339. * @param height ratio up height from 0 to 1
  23340. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23341. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23342. * @returns impostor the soft imposter
  23343. */
  23344. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23345. /**
  23346. * Add a hook to a rope impostor
  23347. * @param otherImpostor rigid impostor to anchor to
  23348. * @param length ratio across rope from 0 to 1
  23349. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23350. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23351. * @returns impostor the rope imposter
  23352. */
  23353. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23354. /**
  23355. * Will keep this body still, in a sleep mode.
  23356. * @returns the physics imposter
  23357. */
  23358. sleep(): PhysicsImpostor;
  23359. /**
  23360. * Wake the body up.
  23361. * @returns The physics imposter
  23362. */
  23363. wakeUp(): PhysicsImpostor;
  23364. /**
  23365. * Clones the physics imposter
  23366. * @param newObject The physics imposter clones to this physics-enabled object
  23367. * @returns A nullable physics imposter
  23368. */
  23369. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23370. /**
  23371. * Disposes the physics imposter
  23372. */
  23373. dispose(): void;
  23374. /**
  23375. * Sets the delta position
  23376. * @param position The delta position amount
  23377. */
  23378. setDeltaPosition(position: Vector3): void;
  23379. /**
  23380. * Sets the delta rotation
  23381. * @param rotation The delta rotation amount
  23382. */
  23383. setDeltaRotation(rotation: Quaternion): void;
  23384. /**
  23385. * Gets the box size of the physics imposter and stores the result in the input parameter
  23386. * @param result Stores the box size
  23387. * @returns The physics imposter
  23388. */
  23389. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23390. /**
  23391. * Gets the radius of the physics imposter
  23392. * @returns Radius of the physics imposter
  23393. */
  23394. getRadius(): number;
  23395. /**
  23396. * Sync a bone with this impostor
  23397. * @param bone The bone to sync to the impostor.
  23398. * @param boneMesh The mesh that the bone is influencing.
  23399. * @param jointPivot The pivot of the joint / bone in local space.
  23400. * @param distToJoint Optional distance from the impostor to the joint.
  23401. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23402. */
  23403. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23404. /**
  23405. * Sync impostor to a bone
  23406. * @param bone The bone that the impostor will be synced to.
  23407. * @param boneMesh The mesh that the bone is influencing.
  23408. * @param jointPivot The pivot of the joint / bone in local space.
  23409. * @param distToJoint Optional distance from the impostor to the joint.
  23410. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23411. * @param boneAxis Optional vector3 axis the bone is aligned with
  23412. */
  23413. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23414. /**
  23415. * No-Imposter type
  23416. */
  23417. static NoImpostor: number;
  23418. /**
  23419. * Sphere-Imposter type
  23420. */
  23421. static SphereImpostor: number;
  23422. /**
  23423. * Box-Imposter type
  23424. */
  23425. static BoxImpostor: number;
  23426. /**
  23427. * Plane-Imposter type
  23428. */
  23429. static PlaneImpostor: number;
  23430. /**
  23431. * Mesh-imposter type
  23432. */
  23433. static MeshImpostor: number;
  23434. /**
  23435. * Capsule-Impostor type (Ammo.js plugin only)
  23436. */
  23437. static CapsuleImpostor: number;
  23438. /**
  23439. * Cylinder-Imposter type
  23440. */
  23441. static CylinderImpostor: number;
  23442. /**
  23443. * Particle-Imposter type
  23444. */
  23445. static ParticleImpostor: number;
  23446. /**
  23447. * Heightmap-Imposter type
  23448. */
  23449. static HeightmapImpostor: number;
  23450. /**
  23451. * ConvexHull-Impostor type (Ammo.js plugin only)
  23452. */
  23453. static ConvexHullImpostor: number;
  23454. /**
  23455. * Rope-Imposter type
  23456. */
  23457. static RopeImpostor: number;
  23458. /**
  23459. * Cloth-Imposter type
  23460. */
  23461. static ClothImpostor: number;
  23462. /**
  23463. * Softbody-Imposter type
  23464. */
  23465. static SoftbodyImpostor: number;
  23466. }
  23467. }
  23468. declare module BABYLON {
  23469. /**
  23470. * @hidden
  23471. **/
  23472. export class _CreationDataStorage {
  23473. closePath?: boolean;
  23474. closeArray?: boolean;
  23475. idx: number[];
  23476. dashSize: number;
  23477. gapSize: number;
  23478. path3D: Path3D;
  23479. pathArray: Vector3[][];
  23480. arc: number;
  23481. radius: number;
  23482. cap: number;
  23483. tessellation: number;
  23484. }
  23485. /**
  23486. * @hidden
  23487. **/
  23488. class _InstanceDataStorage {
  23489. visibleInstances: any;
  23490. batchCache: _InstancesBatch;
  23491. instancesBufferSize: number;
  23492. instancesBuffer: Nullable<Buffer>;
  23493. instancesData: Float32Array;
  23494. overridenInstanceCount: number;
  23495. isFrozen: boolean;
  23496. previousBatch: Nullable<_InstancesBatch>;
  23497. hardwareInstancedRendering: boolean;
  23498. sideOrientation: number;
  23499. }
  23500. /**
  23501. * @hidden
  23502. **/
  23503. export class _InstancesBatch {
  23504. mustReturn: boolean;
  23505. visibleInstances: Nullable<InstancedMesh[]>[];
  23506. renderSelf: boolean[];
  23507. hardwareInstancedRendering: boolean[];
  23508. }
  23509. /**
  23510. * Class used to represent renderable models
  23511. */
  23512. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23513. /**
  23514. * Mesh side orientation : usually the external or front surface
  23515. */
  23516. static readonly FRONTSIDE: number;
  23517. /**
  23518. * Mesh side orientation : usually the internal or back surface
  23519. */
  23520. static readonly BACKSIDE: number;
  23521. /**
  23522. * Mesh side orientation : both internal and external or front and back surfaces
  23523. */
  23524. static readonly DOUBLESIDE: number;
  23525. /**
  23526. * Mesh side orientation : by default, `FRONTSIDE`
  23527. */
  23528. static readonly DEFAULTSIDE: number;
  23529. /**
  23530. * Mesh cap setting : no cap
  23531. */
  23532. static readonly NO_CAP: number;
  23533. /**
  23534. * Mesh cap setting : one cap at the beginning of the mesh
  23535. */
  23536. static readonly CAP_START: number;
  23537. /**
  23538. * Mesh cap setting : one cap at the end of the mesh
  23539. */
  23540. static readonly CAP_END: number;
  23541. /**
  23542. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23543. */
  23544. static readonly CAP_ALL: number;
  23545. /**
  23546. * Mesh pattern setting : no flip or rotate
  23547. */
  23548. static readonly NO_FLIP: number;
  23549. /**
  23550. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23551. */
  23552. static readonly FLIP_TILE: number;
  23553. /**
  23554. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23555. */
  23556. static readonly ROTATE_TILE: number;
  23557. /**
  23558. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23559. */
  23560. static readonly FLIP_ROW: number;
  23561. /**
  23562. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23563. */
  23564. static readonly ROTATE_ROW: number;
  23565. /**
  23566. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23567. */
  23568. static readonly FLIP_N_ROTATE_TILE: number;
  23569. /**
  23570. * Mesh pattern setting : rotate pattern and rotate
  23571. */
  23572. static readonly FLIP_N_ROTATE_ROW: number;
  23573. /**
  23574. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23575. */
  23576. static readonly CENTER: number;
  23577. /**
  23578. * Mesh tile positioning : part tiles on left
  23579. */
  23580. static readonly LEFT: number;
  23581. /**
  23582. * Mesh tile positioning : part tiles on right
  23583. */
  23584. static readonly RIGHT: number;
  23585. /**
  23586. * Mesh tile positioning : part tiles on top
  23587. */
  23588. static readonly TOP: number;
  23589. /**
  23590. * Mesh tile positioning : part tiles on bottom
  23591. */
  23592. static readonly BOTTOM: number;
  23593. /**
  23594. * Gets the default side orientation.
  23595. * @param orientation the orientation to value to attempt to get
  23596. * @returns the default orientation
  23597. * @hidden
  23598. */
  23599. static _GetDefaultSideOrientation(orientation?: number): number;
  23600. private _internalMeshDataInfo;
  23601. /**
  23602. * An event triggered before rendering the mesh
  23603. */
  23604. readonly onBeforeRenderObservable: Observable<Mesh>;
  23605. /**
  23606. * An event triggered before binding the mesh
  23607. */
  23608. readonly onBeforeBindObservable: Observable<Mesh>;
  23609. /**
  23610. * An event triggered after rendering the mesh
  23611. */
  23612. readonly onAfterRenderObservable: Observable<Mesh>;
  23613. /**
  23614. * An event triggered before drawing the mesh
  23615. */
  23616. readonly onBeforeDrawObservable: Observable<Mesh>;
  23617. private _onBeforeDrawObserver;
  23618. /**
  23619. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23620. */
  23621. onBeforeDraw: () => void;
  23622. readonly hasInstances: boolean;
  23623. /**
  23624. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23625. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23626. */
  23627. delayLoadState: number;
  23628. /**
  23629. * Gets the list of instances created from this mesh
  23630. * it is not supposed to be modified manually.
  23631. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23632. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23633. */
  23634. instances: InstancedMesh[];
  23635. /**
  23636. * Gets the file containing delay loading data for this mesh
  23637. */
  23638. delayLoadingFile: string;
  23639. /** @hidden */
  23640. _binaryInfo: any;
  23641. /**
  23642. * User defined function used to change how LOD level selection is done
  23643. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23644. */
  23645. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23646. /**
  23647. * Gets or sets the morph target manager
  23648. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23649. */
  23650. morphTargetManager: Nullable<MorphTargetManager>;
  23651. /** @hidden */
  23652. _creationDataStorage: Nullable<_CreationDataStorage>;
  23653. /** @hidden */
  23654. _geometry: Nullable<Geometry>;
  23655. /** @hidden */
  23656. _delayInfo: Array<string>;
  23657. /** @hidden */
  23658. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23659. /** @hidden */
  23660. _instanceDataStorage: _InstanceDataStorage;
  23661. private _effectiveMaterial;
  23662. /** @hidden */
  23663. _shouldGenerateFlatShading: boolean;
  23664. /** @hidden */
  23665. _originalBuilderSideOrientation: number;
  23666. /**
  23667. * Use this property to change the original side orientation defined at construction time
  23668. */
  23669. overrideMaterialSideOrientation: Nullable<number>;
  23670. /**
  23671. * Gets the source mesh (the one used to clone this one from)
  23672. */
  23673. readonly source: Nullable<Mesh>;
  23674. /**
  23675. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23676. */
  23677. isUnIndexed: boolean;
  23678. /**
  23679. * @constructor
  23680. * @param name The value used by scene.getMeshByName() to do a lookup.
  23681. * @param scene The scene to add this mesh to.
  23682. * @param parent The parent of this mesh, if it has one
  23683. * @param source An optional Mesh from which geometry is shared, cloned.
  23684. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23685. * When false, achieved by calling a clone(), also passing False.
  23686. * This will make creation of children, recursive.
  23687. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23688. */
  23689. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23690. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23691. /**
  23692. * Gets the class name
  23693. * @returns the string "Mesh".
  23694. */
  23695. getClassName(): string;
  23696. /** @hidden */
  23697. readonly _isMesh: boolean;
  23698. /**
  23699. * Returns a description of this mesh
  23700. * @param fullDetails define if full details about this mesh must be used
  23701. * @returns a descriptive string representing this mesh
  23702. */
  23703. toString(fullDetails?: boolean): string;
  23704. /** @hidden */
  23705. _unBindEffect(): void;
  23706. /**
  23707. * Gets a boolean indicating if this mesh has LOD
  23708. */
  23709. readonly hasLODLevels: boolean;
  23710. /**
  23711. * Gets the list of MeshLODLevel associated with the current mesh
  23712. * @returns an array of MeshLODLevel
  23713. */
  23714. getLODLevels(): MeshLODLevel[];
  23715. private _sortLODLevels;
  23716. /**
  23717. * Add a mesh as LOD level triggered at the given distance.
  23718. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23719. * @param distance The distance from the center of the object to show this level
  23720. * @param mesh The mesh to be added as LOD level (can be null)
  23721. * @return This mesh (for chaining)
  23722. */
  23723. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23724. /**
  23725. * Returns the LOD level mesh at the passed distance or null if not found.
  23726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23727. * @param distance The distance from the center of the object to show this level
  23728. * @returns a Mesh or `null`
  23729. */
  23730. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23731. /**
  23732. * Remove a mesh from the LOD array
  23733. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23734. * @param mesh defines the mesh to be removed
  23735. * @return This mesh (for chaining)
  23736. */
  23737. removeLODLevel(mesh: Mesh): Mesh;
  23738. /**
  23739. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23740. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23741. * @param camera defines the camera to use to compute distance
  23742. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23743. * @return This mesh (for chaining)
  23744. */
  23745. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23746. /**
  23747. * Gets the mesh internal Geometry object
  23748. */
  23749. readonly geometry: Nullable<Geometry>;
  23750. /**
  23751. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23752. * @returns the total number of vertices
  23753. */
  23754. getTotalVertices(): number;
  23755. /**
  23756. * Returns the content of an associated vertex buffer
  23757. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23758. * - VertexBuffer.PositionKind
  23759. * - VertexBuffer.UVKind
  23760. * - VertexBuffer.UV2Kind
  23761. * - VertexBuffer.UV3Kind
  23762. * - VertexBuffer.UV4Kind
  23763. * - VertexBuffer.UV5Kind
  23764. * - VertexBuffer.UV6Kind
  23765. * - VertexBuffer.ColorKind
  23766. * - VertexBuffer.MatricesIndicesKind
  23767. * - VertexBuffer.MatricesIndicesExtraKind
  23768. * - VertexBuffer.MatricesWeightsKind
  23769. * - VertexBuffer.MatricesWeightsExtraKind
  23770. * @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
  23771. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23772. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23773. */
  23774. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23775. /**
  23776. * Returns the mesh VertexBuffer object from the requested `kind`
  23777. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23778. * - VertexBuffer.PositionKind
  23779. * - VertexBuffer.NormalKind
  23780. * - VertexBuffer.UVKind
  23781. * - VertexBuffer.UV2Kind
  23782. * - VertexBuffer.UV3Kind
  23783. * - VertexBuffer.UV4Kind
  23784. * - VertexBuffer.UV5Kind
  23785. * - VertexBuffer.UV6Kind
  23786. * - VertexBuffer.ColorKind
  23787. * - VertexBuffer.MatricesIndicesKind
  23788. * - VertexBuffer.MatricesIndicesExtraKind
  23789. * - VertexBuffer.MatricesWeightsKind
  23790. * - VertexBuffer.MatricesWeightsExtraKind
  23791. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23792. */
  23793. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23794. /**
  23795. * Tests if a specific vertex buffer is associated with this mesh
  23796. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23797. * - VertexBuffer.PositionKind
  23798. * - VertexBuffer.NormalKind
  23799. * - VertexBuffer.UVKind
  23800. * - VertexBuffer.UV2Kind
  23801. * - VertexBuffer.UV3Kind
  23802. * - VertexBuffer.UV4Kind
  23803. * - VertexBuffer.UV5Kind
  23804. * - VertexBuffer.UV6Kind
  23805. * - VertexBuffer.ColorKind
  23806. * - VertexBuffer.MatricesIndicesKind
  23807. * - VertexBuffer.MatricesIndicesExtraKind
  23808. * - VertexBuffer.MatricesWeightsKind
  23809. * - VertexBuffer.MatricesWeightsExtraKind
  23810. * @returns a boolean
  23811. */
  23812. isVerticesDataPresent(kind: string): boolean;
  23813. /**
  23814. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23815. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23816. * - VertexBuffer.PositionKind
  23817. * - VertexBuffer.UVKind
  23818. * - VertexBuffer.UV2Kind
  23819. * - VertexBuffer.UV3Kind
  23820. * - VertexBuffer.UV4Kind
  23821. * - VertexBuffer.UV5Kind
  23822. * - VertexBuffer.UV6Kind
  23823. * - VertexBuffer.ColorKind
  23824. * - VertexBuffer.MatricesIndicesKind
  23825. * - VertexBuffer.MatricesIndicesExtraKind
  23826. * - VertexBuffer.MatricesWeightsKind
  23827. * - VertexBuffer.MatricesWeightsExtraKind
  23828. * @returns a boolean
  23829. */
  23830. isVertexBufferUpdatable(kind: string): boolean;
  23831. /**
  23832. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23833. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23834. * - VertexBuffer.PositionKind
  23835. * - VertexBuffer.NormalKind
  23836. * - VertexBuffer.UVKind
  23837. * - VertexBuffer.UV2Kind
  23838. * - VertexBuffer.UV3Kind
  23839. * - VertexBuffer.UV4Kind
  23840. * - VertexBuffer.UV5Kind
  23841. * - VertexBuffer.UV6Kind
  23842. * - VertexBuffer.ColorKind
  23843. * - VertexBuffer.MatricesIndicesKind
  23844. * - VertexBuffer.MatricesIndicesExtraKind
  23845. * - VertexBuffer.MatricesWeightsKind
  23846. * - VertexBuffer.MatricesWeightsExtraKind
  23847. * @returns an array of strings
  23848. */
  23849. getVerticesDataKinds(): string[];
  23850. /**
  23851. * Returns a positive integer : the total number of indices in this mesh geometry.
  23852. * @returns the numner of indices or zero if the mesh has no geometry.
  23853. */
  23854. getTotalIndices(): number;
  23855. /**
  23856. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23857. * @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.
  23858. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23859. * @returns the indices array or an empty array if the mesh has no geometry
  23860. */
  23861. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23862. readonly isBlocked: boolean;
  23863. /**
  23864. * Determine if the current mesh is ready to be rendered
  23865. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23866. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23867. * @returns true if all associated assets are ready (material, textures, shaders)
  23868. */
  23869. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23870. /**
  23871. * 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.
  23872. */
  23873. readonly areNormalsFrozen: boolean;
  23874. /**
  23875. * 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.
  23876. * @returns the current mesh
  23877. */
  23878. freezeNormals(): Mesh;
  23879. /**
  23880. * 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
  23881. * @returns the current mesh
  23882. */
  23883. unfreezeNormals(): Mesh;
  23884. /**
  23885. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23886. */
  23887. overridenInstanceCount: number;
  23888. /** @hidden */
  23889. _preActivate(): Mesh;
  23890. /** @hidden */
  23891. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23892. /** @hidden */
  23893. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23894. /**
  23895. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23896. * This means the mesh underlying bounding box and sphere are recomputed.
  23897. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23898. * @returns the current mesh
  23899. */
  23900. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23901. /** @hidden */
  23902. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23903. /**
  23904. * This function will subdivide the mesh into multiple submeshes
  23905. * @param count defines the expected number of submeshes
  23906. */
  23907. subdivide(count: number): void;
  23908. /**
  23909. * Copy a FloatArray into a specific associated vertex buffer
  23910. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23911. * - VertexBuffer.PositionKind
  23912. * - VertexBuffer.UVKind
  23913. * - VertexBuffer.UV2Kind
  23914. * - VertexBuffer.UV3Kind
  23915. * - VertexBuffer.UV4Kind
  23916. * - VertexBuffer.UV5Kind
  23917. * - VertexBuffer.UV6Kind
  23918. * - VertexBuffer.ColorKind
  23919. * - VertexBuffer.MatricesIndicesKind
  23920. * - VertexBuffer.MatricesIndicesExtraKind
  23921. * - VertexBuffer.MatricesWeightsKind
  23922. * - VertexBuffer.MatricesWeightsExtraKind
  23923. * @param data defines the data source
  23924. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23925. * @param stride defines the data stride size (can be null)
  23926. * @returns the current mesh
  23927. */
  23928. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23929. /**
  23930. * Flags an associated vertex buffer as updatable
  23931. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23932. * - VertexBuffer.PositionKind
  23933. * - VertexBuffer.UVKind
  23934. * - VertexBuffer.UV2Kind
  23935. * - VertexBuffer.UV3Kind
  23936. * - VertexBuffer.UV4Kind
  23937. * - VertexBuffer.UV5Kind
  23938. * - VertexBuffer.UV6Kind
  23939. * - VertexBuffer.ColorKind
  23940. * - VertexBuffer.MatricesIndicesKind
  23941. * - VertexBuffer.MatricesIndicesExtraKind
  23942. * - VertexBuffer.MatricesWeightsKind
  23943. * - VertexBuffer.MatricesWeightsExtraKind
  23944. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23945. */
  23946. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23947. /**
  23948. * Sets the mesh global Vertex Buffer
  23949. * @param buffer defines the buffer to use
  23950. * @returns the current mesh
  23951. */
  23952. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23953. /**
  23954. * Update a specific associated vertex buffer
  23955. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23956. * - VertexBuffer.PositionKind
  23957. * - VertexBuffer.UVKind
  23958. * - VertexBuffer.UV2Kind
  23959. * - VertexBuffer.UV3Kind
  23960. * - VertexBuffer.UV4Kind
  23961. * - VertexBuffer.UV5Kind
  23962. * - VertexBuffer.UV6Kind
  23963. * - VertexBuffer.ColorKind
  23964. * - VertexBuffer.MatricesIndicesKind
  23965. * - VertexBuffer.MatricesIndicesExtraKind
  23966. * - VertexBuffer.MatricesWeightsKind
  23967. * - VertexBuffer.MatricesWeightsExtraKind
  23968. * @param data defines the data source
  23969. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23970. * @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)
  23971. * @returns the current mesh
  23972. */
  23973. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23974. /**
  23975. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23976. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23977. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23978. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23979. * @returns the current mesh
  23980. */
  23981. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23982. /**
  23983. * Creates a un-shared specific occurence of the geometry for the mesh.
  23984. * @returns the current mesh
  23985. */
  23986. makeGeometryUnique(): Mesh;
  23987. /**
  23988. * Set the index buffer of this mesh
  23989. * @param indices defines the source data
  23990. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23991. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23992. * @returns the current mesh
  23993. */
  23994. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23995. /**
  23996. * Update the current index buffer
  23997. * @param indices defines the source data
  23998. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23999. * @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)
  24000. * @returns the current mesh
  24001. */
  24002. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24003. /**
  24004. * Invert the geometry to move from a right handed system to a left handed one.
  24005. * @returns the current mesh
  24006. */
  24007. toLeftHanded(): Mesh;
  24008. /** @hidden */
  24009. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24010. /** @hidden */
  24011. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24012. /**
  24013. * Registers for this mesh a javascript function called just before the rendering process
  24014. * @param func defines the function to call before rendering this mesh
  24015. * @returns the current mesh
  24016. */
  24017. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24018. /**
  24019. * Disposes a previously registered javascript function called before the rendering
  24020. * @param func defines the function to remove
  24021. * @returns the current mesh
  24022. */
  24023. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24024. /**
  24025. * Registers for this mesh a javascript function called just after the rendering is complete
  24026. * @param func defines the function to call after rendering this mesh
  24027. * @returns the current mesh
  24028. */
  24029. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24030. /**
  24031. * Disposes a previously registered javascript function called after the rendering.
  24032. * @param func defines the function to remove
  24033. * @returns the current mesh
  24034. */
  24035. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24036. /** @hidden */
  24037. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24038. /** @hidden */
  24039. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24040. /** @hidden */
  24041. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24042. /** @hidden */
  24043. _rebuild(): void;
  24044. /** @hidden */
  24045. _freeze(): void;
  24046. /** @hidden */
  24047. _unFreeze(): void;
  24048. /**
  24049. * 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
  24050. * @param subMesh defines the subMesh to render
  24051. * @param enableAlphaMode defines if alpha mode can be changed
  24052. * @returns the current mesh
  24053. */
  24054. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24055. private _onBeforeDraw;
  24056. /**
  24057. * Renormalize the mesh and patch it up if there are no weights
  24058. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24059. * However in the case of zero weights then we set just a single influence to 1.
  24060. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24061. */
  24062. cleanMatrixWeights(): void;
  24063. private normalizeSkinFourWeights;
  24064. private normalizeSkinWeightsAndExtra;
  24065. /**
  24066. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24067. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24068. * the user know there was an issue with importing the mesh
  24069. * @returns a validation object with skinned, valid and report string
  24070. */
  24071. validateSkinning(): {
  24072. skinned: boolean;
  24073. valid: boolean;
  24074. report: string;
  24075. };
  24076. /** @hidden */
  24077. _checkDelayState(): Mesh;
  24078. private _queueLoad;
  24079. /**
  24080. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24081. * A mesh is in the frustum if its bounding box intersects the frustum
  24082. * @param frustumPlanes defines the frustum to test
  24083. * @returns true if the mesh is in the frustum planes
  24084. */
  24085. isInFrustum(frustumPlanes: Plane[]): boolean;
  24086. /**
  24087. * Sets the mesh material by the material or multiMaterial `id` property
  24088. * @param id is a string identifying the material or the multiMaterial
  24089. * @returns the current mesh
  24090. */
  24091. setMaterialByID(id: string): Mesh;
  24092. /**
  24093. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24094. * @returns an array of IAnimatable
  24095. */
  24096. getAnimatables(): IAnimatable[];
  24097. /**
  24098. * Modifies the mesh geometry according to the passed transformation matrix.
  24099. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24100. * The mesh normals are modified using the same transformation.
  24101. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24102. * @param transform defines the transform matrix to use
  24103. * @see http://doc.babylonjs.com/resources/baking_transformations
  24104. * @returns the current mesh
  24105. */
  24106. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24107. /**
  24108. * Modifies the mesh geometry according to its own current World Matrix.
  24109. * The mesh World Matrix is then reset.
  24110. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24111. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24112. * @see http://doc.babylonjs.com/resources/baking_transformations
  24113. * @returns the current mesh
  24114. */
  24115. bakeCurrentTransformIntoVertices(): Mesh;
  24116. /** @hidden */
  24117. readonly _positions: Nullable<Vector3[]>;
  24118. /** @hidden */
  24119. _resetPointsArrayCache(): Mesh;
  24120. /** @hidden */
  24121. _generatePointsArray(): boolean;
  24122. /**
  24123. * Returns a new Mesh object generated from the current mesh properties.
  24124. * This method must not get confused with createInstance()
  24125. * @param name is a string, the name given to the new mesh
  24126. * @param newParent can be any Node object (default `null`)
  24127. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24128. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24129. * @returns a new mesh
  24130. */
  24131. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24132. /**
  24133. * Releases resources associated with this mesh.
  24134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24136. */
  24137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24138. /**
  24139. * Modifies the mesh geometry according to a displacement map.
  24140. * 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.
  24141. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24142. * @param url is a string, the URL from the image file is to be downloaded.
  24143. * @param minHeight is the lower limit of the displacement.
  24144. * @param maxHeight is the upper limit of the displacement.
  24145. * @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.
  24146. * @param uvOffset is an optional vector2 used to offset UV.
  24147. * @param uvScale is an optional vector2 used to scale UV.
  24148. * @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.
  24149. * @returns the Mesh.
  24150. */
  24151. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24152. /**
  24153. * Modifies the mesh geometry according to a displacementMap buffer.
  24154. * 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.
  24155. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24156. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24157. * @param heightMapWidth is the width of the buffer image.
  24158. * @param heightMapHeight is the height of the buffer image.
  24159. * @param minHeight is the lower limit of the displacement.
  24160. * @param maxHeight is the upper limit of the displacement.
  24161. * @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.
  24162. * @param uvOffset is an optional vector2 used to offset UV.
  24163. * @param uvScale is an optional vector2 used to scale UV.
  24164. * @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.
  24165. * @returns the Mesh.
  24166. */
  24167. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24168. /**
  24169. * Modify the mesh to get a flat shading rendering.
  24170. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24171. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24172. * @returns current mesh
  24173. */
  24174. convertToFlatShadedMesh(): Mesh;
  24175. /**
  24176. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24177. * In other words, more vertices, no more indices and a single bigger VBO.
  24178. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24179. * @returns current mesh
  24180. */
  24181. convertToUnIndexedMesh(): Mesh;
  24182. /**
  24183. * Inverses facet orientations.
  24184. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24185. * @param flipNormals will also inverts the normals
  24186. * @returns current mesh
  24187. */
  24188. flipFaces(flipNormals?: boolean): Mesh;
  24189. /**
  24190. * Increase the number of facets and hence vertices in a mesh
  24191. * Vertex normals are interpolated from existing vertex normals
  24192. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24193. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24194. */
  24195. increaseVertices(numberPerEdge: number): void;
  24196. /**
  24197. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24198. * This will undo any application of covertToFlatShadedMesh
  24199. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24200. */
  24201. forceSharedVertices(): void;
  24202. /** @hidden */
  24203. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24204. /** @hidden */
  24205. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24206. /**
  24207. * Creates a new InstancedMesh object from the mesh model.
  24208. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24209. * @param name defines the name of the new instance
  24210. * @returns a new InstancedMesh
  24211. */
  24212. createInstance(name: string): InstancedMesh;
  24213. /**
  24214. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24215. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24216. * @returns the current mesh
  24217. */
  24218. synchronizeInstances(): Mesh;
  24219. /**
  24220. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24221. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24222. * This should be used together with the simplification to avoid disappearing triangles.
  24223. * @param successCallback an optional success callback to be called after the optimization finished.
  24224. * @returns the current mesh
  24225. */
  24226. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24227. /**
  24228. * Serialize current mesh
  24229. * @param serializationObject defines the object which will receive the serialization data
  24230. */
  24231. serialize(serializationObject: any): void;
  24232. /** @hidden */
  24233. _syncGeometryWithMorphTargetManager(): void;
  24234. /** @hidden */
  24235. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24236. /**
  24237. * Returns a new Mesh object parsed from the source provided.
  24238. * @param parsedMesh is the source
  24239. * @param scene defines the hosting scene
  24240. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24241. * @returns a new Mesh
  24242. */
  24243. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24244. /**
  24245. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24246. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24247. * @param name defines the name of the mesh to create
  24248. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24249. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24250. * @param closePath creates a seam between the first and the last points of each path of the path array
  24251. * @param offset is taken in account only if the `pathArray` is containing a single path
  24252. * @param scene defines the hosting scene
  24253. * @param updatable defines if the mesh must be flagged as updatable
  24254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24255. * @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)
  24256. * @returns a new Mesh
  24257. */
  24258. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24259. /**
  24260. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24261. * @param name defines the name of the mesh to create
  24262. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24263. * @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
  24264. * @param scene defines the hosting scene
  24265. * @param updatable defines if the mesh must be flagged as updatable
  24266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24267. * @returns a new Mesh
  24268. */
  24269. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24270. /**
  24271. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24272. * @param name defines the name of the mesh to create
  24273. * @param size sets the size (float) of each box side (default 1)
  24274. * @param scene defines the hosting scene
  24275. * @param updatable defines if the mesh must be flagged as updatable
  24276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24277. * @returns a new Mesh
  24278. */
  24279. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24280. /**
  24281. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24282. * @param name defines the name of the mesh to create
  24283. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24284. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24285. * @param scene defines the hosting scene
  24286. * @param updatable defines if the mesh must be flagged as updatable
  24287. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24288. * @returns a new Mesh
  24289. */
  24290. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24291. /**
  24292. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24293. * @param name defines the name of the mesh to create
  24294. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24295. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24296. * @param scene defines the hosting scene
  24297. * @returns a new Mesh
  24298. */
  24299. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24300. /**
  24301. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24302. * @param name defines the name of the mesh to create
  24303. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24304. * @param diameterTop set the top cap diameter (floats, default 1)
  24305. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24306. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24307. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24308. * @param scene defines the hosting scene
  24309. * @param updatable defines if the mesh must be flagged as updatable
  24310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24311. * @returns a new Mesh
  24312. */
  24313. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24314. /**
  24315. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24316. * @param name defines the name of the mesh to create
  24317. * @param diameter sets the diameter size (float) of the torus (default 1)
  24318. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24319. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24320. * @param scene defines the hosting scene
  24321. * @param updatable defines if the mesh must be flagged as updatable
  24322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24323. * @returns a new Mesh
  24324. */
  24325. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24326. /**
  24327. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24328. * @param name defines the name of the mesh to create
  24329. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24330. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24331. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24332. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24333. * @param p the number of windings on X axis (positive integers, default 2)
  24334. * @param q the number of windings on Y axis (positive integers, default 3)
  24335. * @param scene defines the hosting scene
  24336. * @param updatable defines if the mesh must be flagged as updatable
  24337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24338. * @returns a new Mesh
  24339. */
  24340. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24341. /**
  24342. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24343. * @param name defines the name of the mesh to create
  24344. * @param points is an array successive Vector3
  24345. * @param scene defines the hosting scene
  24346. * @param updatable defines if the mesh must be flagged as updatable
  24347. * @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).
  24348. * @returns a new Mesh
  24349. */
  24350. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24351. /**
  24352. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24353. * @param name defines the name of the mesh to create
  24354. * @param points is an array successive Vector3
  24355. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24356. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24357. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24358. * @param scene defines the hosting scene
  24359. * @param updatable defines if the mesh must be flagged as updatable
  24360. * @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)
  24361. * @returns a new Mesh
  24362. */
  24363. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24364. /**
  24365. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24366. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24367. * 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.
  24368. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24370. * Remember you can only change the shape positions, not their number when updating a polygon.
  24371. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24372. * @param name defines the name of the mesh to create
  24373. * @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
  24374. * @param scene defines the hosting scene
  24375. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24376. * @param updatable defines if the mesh must be flagged as updatable
  24377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24378. * @param earcutInjection can be used to inject your own earcut reference
  24379. * @returns a new Mesh
  24380. */
  24381. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24382. /**
  24383. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24384. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24385. * @param name defines the name of the mesh to create
  24386. * @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
  24387. * @param depth defines the height of extrusion
  24388. * @param scene defines the hosting scene
  24389. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24390. * @param updatable defines if the mesh must be flagged as updatable
  24391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24392. * @param earcutInjection can be used to inject your own earcut reference
  24393. * @returns a new Mesh
  24394. */
  24395. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24396. /**
  24397. * Creates an extruded shape mesh.
  24398. * 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
  24399. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24400. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24401. * @param name defines the name of the mesh to create
  24402. * @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
  24403. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24404. * @param scale is the value to scale the shape
  24405. * @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
  24406. * @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
  24407. * @param scene defines the hosting scene
  24408. * @param updatable defines if the mesh must be flagged as updatable
  24409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24410. * @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)
  24411. * @returns a new Mesh
  24412. */
  24413. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24414. /**
  24415. * Creates an custom extruded shape mesh.
  24416. * The custom extrusion is a parametric shape.
  24417. * It has no predefined shape. Its final shape will depend on the input parameters.
  24418. * Please consider using the same method from the MeshBuilder class instead
  24419. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24420. * @param name defines the name of the mesh to create
  24421. * @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
  24422. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24423. * @param scaleFunction is a custom Javascript function called on each path point
  24424. * @param rotationFunction is a custom Javascript function called on each path point
  24425. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24426. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24427. * @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
  24428. * @param scene defines the hosting scene
  24429. * @param updatable defines if the mesh must be flagged as updatable
  24430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24431. * @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)
  24432. * @returns a new Mesh
  24433. */
  24434. 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;
  24435. /**
  24436. * Creates lathe mesh.
  24437. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24438. * Please consider using the same method from the MeshBuilder class instead
  24439. * @param name defines the name of the mesh to create
  24440. * @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
  24441. * @param radius is the radius value of the lathe
  24442. * @param tessellation is the side number of the lathe.
  24443. * @param scene defines the hosting scene
  24444. * @param updatable defines if the mesh must be flagged as updatable
  24445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24446. * @returns a new Mesh
  24447. */
  24448. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24449. /**
  24450. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24451. * @param name defines the name of the mesh to create
  24452. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24453. * @param scene defines the hosting scene
  24454. * @param updatable defines if the mesh must be flagged as updatable
  24455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24456. * @returns a new Mesh
  24457. */
  24458. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24459. /**
  24460. * Creates a ground mesh.
  24461. * Please consider using the same method from the MeshBuilder class instead
  24462. * @param name defines the name of the mesh to create
  24463. * @param width set the width of the ground
  24464. * @param height set the height of the ground
  24465. * @param subdivisions sets the number of subdivisions per side
  24466. * @param scene defines the hosting scene
  24467. * @param updatable defines if the mesh must be flagged as updatable
  24468. * @returns a new Mesh
  24469. */
  24470. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24471. /**
  24472. * Creates a tiled ground mesh.
  24473. * Please consider using the same method from the MeshBuilder class instead
  24474. * @param name defines the name of the mesh to create
  24475. * @param xmin set the ground minimum X coordinate
  24476. * @param zmin set the ground minimum Y coordinate
  24477. * @param xmax set the ground maximum X coordinate
  24478. * @param zmax set the ground maximum Z coordinate
  24479. * @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
  24480. * @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
  24481. * @param scene defines the hosting scene
  24482. * @param updatable defines if the mesh must be flagged as updatable
  24483. * @returns a new Mesh
  24484. */
  24485. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24486. w: number;
  24487. h: number;
  24488. }, precision: {
  24489. w: number;
  24490. h: number;
  24491. }, scene: Scene, updatable?: boolean): Mesh;
  24492. /**
  24493. * Creates a ground mesh from a height map.
  24494. * Please consider using the same method from the MeshBuilder class instead
  24495. * @see http://doc.babylonjs.com/babylon101/height_map
  24496. * @param name defines the name of the mesh to create
  24497. * @param url sets the URL of the height map image resource
  24498. * @param width set the ground width size
  24499. * @param height set the ground height size
  24500. * @param subdivisions sets the number of subdivision per side
  24501. * @param minHeight is the minimum altitude on the ground
  24502. * @param maxHeight is the maximum altitude on the ground
  24503. * @param scene defines the hosting scene
  24504. * @param updatable defines if the mesh must be flagged as updatable
  24505. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24506. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24507. * @returns a new Mesh
  24508. */
  24509. 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;
  24510. /**
  24511. * Creates a tube mesh.
  24512. * The tube is a parametric shape.
  24513. * It has no predefined shape. Its final shape will depend on the input parameters.
  24514. * Please consider using the same method from the MeshBuilder class instead
  24515. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24516. * @param name defines the name of the mesh to create
  24517. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24518. * @param radius sets the tube radius size
  24519. * @param tessellation is the number of sides on the tubular surface
  24520. * @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
  24521. * @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
  24522. * @param scene defines the hosting scene
  24523. * @param updatable defines if the mesh must be flagged as updatable
  24524. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24525. * @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)
  24526. * @returns a new Mesh
  24527. */
  24528. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24529. (i: number, distance: number): number;
  24530. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24531. /**
  24532. * Creates a polyhedron mesh.
  24533. * Please consider using the same method from the MeshBuilder class instead.
  24534. * * 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
  24535. * * The parameter `size` (positive float, default 1) sets the polygon size
  24536. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24537. * * 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`
  24538. * * 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
  24539. * * 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)`)
  24540. * * 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
  24541. * * 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
  24542. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24543. * * 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
  24544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24545. * @param name defines the name of the mesh to create
  24546. * @param options defines the options used to create the mesh
  24547. * @param scene defines the hosting scene
  24548. * @returns a new Mesh
  24549. */
  24550. static CreatePolyhedron(name: string, options: {
  24551. type?: number;
  24552. size?: number;
  24553. sizeX?: number;
  24554. sizeY?: number;
  24555. sizeZ?: number;
  24556. custom?: any;
  24557. faceUV?: Vector4[];
  24558. faceColors?: Color4[];
  24559. updatable?: boolean;
  24560. sideOrientation?: number;
  24561. }, scene: Scene): Mesh;
  24562. /**
  24563. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24564. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24565. * * 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`)
  24566. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24567. * * 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
  24568. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24569. * * 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
  24570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24571. * @param name defines the name of the mesh
  24572. * @param options defines the options used to create the mesh
  24573. * @param scene defines the hosting scene
  24574. * @returns a new Mesh
  24575. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24576. */
  24577. static CreateIcoSphere(name: string, options: {
  24578. radius?: number;
  24579. flat?: boolean;
  24580. subdivisions?: number;
  24581. sideOrientation?: number;
  24582. updatable?: boolean;
  24583. }, scene: Scene): Mesh;
  24584. /**
  24585. * Creates a decal mesh.
  24586. * Please consider using the same method from the MeshBuilder class instead.
  24587. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24588. * @param name defines the name of the mesh
  24589. * @param sourceMesh defines the mesh receiving the decal
  24590. * @param position sets the position of the decal in world coordinates
  24591. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24592. * @param size sets the decal scaling
  24593. * @param angle sets the angle to rotate the decal
  24594. * @returns a new Mesh
  24595. */
  24596. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24597. /**
  24598. * Prepare internal position array for software CPU skinning
  24599. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24600. */
  24601. setPositionsForCPUSkinning(): Float32Array;
  24602. /**
  24603. * Prepare internal normal array for software CPU skinning
  24604. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24605. */
  24606. setNormalsForCPUSkinning(): Float32Array;
  24607. /**
  24608. * Updates the vertex buffer by applying transformation from the bones
  24609. * @param skeleton defines the skeleton to apply to current mesh
  24610. * @returns the current mesh
  24611. */
  24612. applySkeleton(skeleton: Skeleton): Mesh;
  24613. /**
  24614. * 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
  24615. * @param meshes defines the list of meshes to scan
  24616. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24617. */
  24618. static MinMax(meshes: AbstractMesh[]): {
  24619. min: Vector3;
  24620. max: Vector3;
  24621. };
  24622. /**
  24623. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24624. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24625. * @returns a vector3
  24626. */
  24627. static Center(meshesOrMinMaxVector: {
  24628. min: Vector3;
  24629. max: Vector3;
  24630. } | AbstractMesh[]): Vector3;
  24631. /**
  24632. * Merge the array of meshes into a single mesh for performance reasons.
  24633. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24634. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24635. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24636. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24637. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24638. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24639. * @returns a new mesh
  24640. */
  24641. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24642. /** @hidden */
  24643. addInstance(instance: InstancedMesh): void;
  24644. /** @hidden */
  24645. removeInstance(instance: InstancedMesh): void;
  24646. }
  24647. }
  24648. declare module BABYLON {
  24649. /**
  24650. * This is the base class of all the camera used in the application.
  24651. * @see http://doc.babylonjs.com/features/cameras
  24652. */
  24653. export class Camera extends Node {
  24654. /** @hidden */
  24655. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24656. /**
  24657. * This is the default projection mode used by the cameras.
  24658. * It helps recreating a feeling of perspective and better appreciate depth.
  24659. * This is the best way to simulate real life cameras.
  24660. */
  24661. static readonly PERSPECTIVE_CAMERA: number;
  24662. /**
  24663. * This helps creating camera with an orthographic mode.
  24664. * 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.
  24665. */
  24666. static readonly ORTHOGRAPHIC_CAMERA: number;
  24667. /**
  24668. * This is the default FOV mode for perspective cameras.
  24669. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24670. */
  24671. static readonly FOVMODE_VERTICAL_FIXED: number;
  24672. /**
  24673. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24674. */
  24675. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24676. /**
  24677. * This specifies ther is no need for a camera rig.
  24678. * Basically only one eye is rendered corresponding to the camera.
  24679. */
  24680. static readonly RIG_MODE_NONE: number;
  24681. /**
  24682. * Simulates a camera Rig with one blue eye and one red eye.
  24683. * This can be use with 3d blue and red glasses.
  24684. */
  24685. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24686. /**
  24687. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24688. */
  24689. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24690. /**
  24691. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24692. */
  24693. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24694. /**
  24695. * Defines that both eyes of the camera will be rendered over under each other.
  24696. */
  24697. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24698. /**
  24699. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24700. */
  24701. static readonly RIG_MODE_VR: number;
  24702. /**
  24703. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24704. */
  24705. static readonly RIG_MODE_WEBVR: number;
  24706. /**
  24707. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24708. */
  24709. static readonly RIG_MODE_CUSTOM: number;
  24710. /**
  24711. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24712. */
  24713. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24714. /**
  24715. * Define the input manager associated with the camera.
  24716. */
  24717. inputs: CameraInputsManager<Camera>;
  24718. /** @hidden */
  24719. _position: Vector3;
  24720. /**
  24721. * Define the current local position of the camera in the scene
  24722. */
  24723. position: Vector3;
  24724. /**
  24725. * The vector the camera should consider as up.
  24726. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24727. */
  24728. upVector: Vector3;
  24729. /**
  24730. * Define the current limit on the left side for an orthographic camera
  24731. * In scene unit
  24732. */
  24733. orthoLeft: Nullable<number>;
  24734. /**
  24735. * Define the current limit on the right side for an orthographic camera
  24736. * In scene unit
  24737. */
  24738. orthoRight: Nullable<number>;
  24739. /**
  24740. * Define the current limit on the bottom side for an orthographic camera
  24741. * In scene unit
  24742. */
  24743. orthoBottom: Nullable<number>;
  24744. /**
  24745. * Define the current limit on the top side for an orthographic camera
  24746. * In scene unit
  24747. */
  24748. orthoTop: Nullable<number>;
  24749. /**
  24750. * Field Of View is set in Radians. (default is 0.8)
  24751. */
  24752. fov: number;
  24753. /**
  24754. * Define the minimum distance the camera can see from.
  24755. * This is important to note that the depth buffer are not infinite and the closer it starts
  24756. * the more your scene might encounter depth fighting issue.
  24757. */
  24758. minZ: number;
  24759. /**
  24760. * Define the maximum distance the camera can see to.
  24761. * This is important to note that the depth buffer are not infinite and the further it end
  24762. * the more your scene might encounter depth fighting issue.
  24763. */
  24764. maxZ: number;
  24765. /**
  24766. * Define the default inertia of the camera.
  24767. * This helps giving a smooth feeling to the camera movement.
  24768. */
  24769. inertia: number;
  24770. /**
  24771. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24772. */
  24773. mode: number;
  24774. /**
  24775. * Define wether the camera is intermediate.
  24776. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24777. */
  24778. isIntermediate: boolean;
  24779. /**
  24780. * Define the viewport of the camera.
  24781. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24782. */
  24783. viewport: Viewport;
  24784. /**
  24785. * Restricts the camera to viewing objects with the same layerMask.
  24786. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24787. */
  24788. layerMask: number;
  24789. /**
  24790. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24791. */
  24792. fovMode: number;
  24793. /**
  24794. * Rig mode of the camera.
  24795. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24796. * This is normally controlled byt the camera themselves as internal use.
  24797. */
  24798. cameraRigMode: number;
  24799. /**
  24800. * Defines the distance between both "eyes" in case of a RIG
  24801. */
  24802. interaxialDistance: number;
  24803. /**
  24804. * Defines if stereoscopic rendering is done side by side or over under.
  24805. */
  24806. isStereoscopicSideBySide: boolean;
  24807. /**
  24808. * 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
  24809. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24810. * else in the scene. (Eg. security camera)
  24811. *
  24812. * 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)
  24813. */
  24814. customRenderTargets: RenderTargetTexture[];
  24815. /**
  24816. * When set, the camera will render to this render target instead of the default canvas
  24817. *
  24818. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24819. */
  24820. outputRenderTarget: Nullable<RenderTargetTexture>;
  24821. /**
  24822. * Observable triggered when the camera view matrix has changed.
  24823. */
  24824. onViewMatrixChangedObservable: Observable<Camera>;
  24825. /**
  24826. * Observable triggered when the camera Projection matrix has changed.
  24827. */
  24828. onProjectionMatrixChangedObservable: Observable<Camera>;
  24829. /**
  24830. * Observable triggered when the inputs have been processed.
  24831. */
  24832. onAfterCheckInputsObservable: Observable<Camera>;
  24833. /**
  24834. * Observable triggered when reset has been called and applied to the camera.
  24835. */
  24836. onRestoreStateObservable: Observable<Camera>;
  24837. /** @hidden */
  24838. _cameraRigParams: any;
  24839. /** @hidden */
  24840. _rigCameras: Camera[];
  24841. /** @hidden */
  24842. _rigPostProcess: Nullable<PostProcess>;
  24843. protected _webvrViewMatrix: Matrix;
  24844. /** @hidden */
  24845. _skipRendering: boolean;
  24846. /** @hidden */
  24847. _projectionMatrix: Matrix;
  24848. /** @hidden */
  24849. _postProcesses: Nullable<PostProcess>[];
  24850. /** @hidden */
  24851. _activeMeshes: SmartArray<AbstractMesh>;
  24852. protected _globalPosition: Vector3;
  24853. /** @hidden */
  24854. _computedViewMatrix: Matrix;
  24855. private _doNotComputeProjectionMatrix;
  24856. private _transformMatrix;
  24857. private _frustumPlanes;
  24858. private _refreshFrustumPlanes;
  24859. private _storedFov;
  24860. private _stateStored;
  24861. /**
  24862. * Instantiates a new camera object.
  24863. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24864. * @see http://doc.babylonjs.com/features/cameras
  24865. * @param name Defines the name of the camera in the scene
  24866. * @param position Defines the position of the camera
  24867. * @param scene Defines the scene the camera belongs too
  24868. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24869. */
  24870. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24871. /**
  24872. * Store current camera state (fov, position, etc..)
  24873. * @returns the camera
  24874. */
  24875. storeState(): Camera;
  24876. /**
  24877. * Restores the camera state values if it has been stored. You must call storeState() first
  24878. */
  24879. protected _restoreStateValues(): boolean;
  24880. /**
  24881. * Restored camera state. You must call storeState() first.
  24882. * @returns true if restored and false otherwise
  24883. */
  24884. restoreState(): boolean;
  24885. /**
  24886. * Gets the class name of the camera.
  24887. * @returns the class name
  24888. */
  24889. getClassName(): string;
  24890. /** @hidden */
  24891. readonly _isCamera: boolean;
  24892. /**
  24893. * Gets a string representation of the camera useful for debug purpose.
  24894. * @param fullDetails Defines that a more verboe level of logging is required
  24895. * @returns the string representation
  24896. */
  24897. toString(fullDetails?: boolean): string;
  24898. /**
  24899. * Gets the current world space position of the camera.
  24900. */
  24901. readonly globalPosition: Vector3;
  24902. /**
  24903. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24904. * @returns the active meshe list
  24905. */
  24906. getActiveMeshes(): SmartArray<AbstractMesh>;
  24907. /**
  24908. * Check wether a mesh is part of the current active mesh list of the camera
  24909. * @param mesh Defines the mesh to check
  24910. * @returns true if active, false otherwise
  24911. */
  24912. isActiveMesh(mesh: Mesh): boolean;
  24913. /**
  24914. * Is this camera ready to be used/rendered
  24915. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24916. * @return true if the camera is ready
  24917. */
  24918. isReady(completeCheck?: boolean): boolean;
  24919. /** @hidden */
  24920. _initCache(): void;
  24921. /** @hidden */
  24922. _updateCache(ignoreParentClass?: boolean): void;
  24923. /** @hidden */
  24924. _isSynchronized(): boolean;
  24925. /** @hidden */
  24926. _isSynchronizedViewMatrix(): boolean;
  24927. /** @hidden */
  24928. _isSynchronizedProjectionMatrix(): boolean;
  24929. /**
  24930. * Attach the input controls to a specific dom element to get the input from.
  24931. * @param element Defines the element the controls should be listened from
  24932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24933. */
  24934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24935. /**
  24936. * Detach the current controls from the specified dom element.
  24937. * @param element Defines the element to stop listening the inputs from
  24938. */
  24939. detachControl(element: HTMLElement): void;
  24940. /**
  24941. * Update the camera state according to the different inputs gathered during the frame.
  24942. */
  24943. update(): void;
  24944. /** @hidden */
  24945. _checkInputs(): void;
  24946. /** @hidden */
  24947. readonly rigCameras: Camera[];
  24948. /**
  24949. * Gets the post process used by the rig cameras
  24950. */
  24951. readonly rigPostProcess: Nullable<PostProcess>;
  24952. /**
  24953. * Internal, gets the first post proces.
  24954. * @returns the first post process to be run on this camera.
  24955. */
  24956. _getFirstPostProcess(): Nullable<PostProcess>;
  24957. private _cascadePostProcessesToRigCams;
  24958. /**
  24959. * Attach a post process to the camera.
  24960. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24961. * @param postProcess The post process to attach to the camera
  24962. * @param insertAt The position of the post process in case several of them are in use in the scene
  24963. * @returns the position the post process has been inserted at
  24964. */
  24965. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24966. /**
  24967. * Detach a post process to the camera.
  24968. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24969. * @param postProcess The post process to detach from the camera
  24970. */
  24971. detachPostProcess(postProcess: PostProcess): void;
  24972. /**
  24973. * Gets the current world matrix of the camera
  24974. */
  24975. getWorldMatrix(): Matrix;
  24976. /** @hidden */
  24977. _getViewMatrix(): Matrix;
  24978. /**
  24979. * Gets the current view matrix of the camera.
  24980. * @param force forces the camera to recompute the matrix without looking at the cached state
  24981. * @returns the view matrix
  24982. */
  24983. getViewMatrix(force?: boolean): Matrix;
  24984. /**
  24985. * Freeze the projection matrix.
  24986. * It will prevent the cache check of the camera projection compute and can speed up perf
  24987. * if no parameter of the camera are meant to change
  24988. * @param projection Defines manually a projection if necessary
  24989. */
  24990. freezeProjectionMatrix(projection?: Matrix): void;
  24991. /**
  24992. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24993. */
  24994. unfreezeProjectionMatrix(): void;
  24995. /**
  24996. * Gets the current projection matrix of the camera.
  24997. * @param force forces the camera to recompute the matrix without looking at the cached state
  24998. * @returns the projection matrix
  24999. */
  25000. getProjectionMatrix(force?: boolean): Matrix;
  25001. /**
  25002. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25003. * @returns a Matrix
  25004. */
  25005. getTransformationMatrix(): Matrix;
  25006. private _updateFrustumPlanes;
  25007. /**
  25008. * Checks if a cullable object (mesh...) is in the camera frustum
  25009. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25010. * @param target The object to check
  25011. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25012. * @returns true if the object is in frustum otherwise false
  25013. */
  25014. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25015. /**
  25016. * Checks if a cullable object (mesh...) is in the camera frustum
  25017. * Unlike isInFrustum this cheks the full bounding box
  25018. * @param target The object to check
  25019. * @returns true if the object is in frustum otherwise false
  25020. */
  25021. isCompletelyInFrustum(target: ICullable): boolean;
  25022. /**
  25023. * Gets a ray in the forward direction from the camera.
  25024. * @param length Defines the length of the ray to create
  25025. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25026. * @param origin Defines the start point of the ray which defaults to the camera position
  25027. * @returns the forward ray
  25028. */
  25029. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25030. /**
  25031. * Releases resources associated with this node.
  25032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25034. */
  25035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25036. /** @hidden */
  25037. _isLeftCamera: boolean;
  25038. /**
  25039. * Gets the left camera of a rig setup in case of Rigged Camera
  25040. */
  25041. readonly isLeftCamera: boolean;
  25042. /** @hidden */
  25043. _isRightCamera: boolean;
  25044. /**
  25045. * Gets the right camera of a rig setup in case of Rigged Camera
  25046. */
  25047. readonly isRightCamera: boolean;
  25048. /**
  25049. * Gets the left camera of a rig setup in case of Rigged Camera
  25050. */
  25051. readonly leftCamera: Nullable<FreeCamera>;
  25052. /**
  25053. * Gets the right camera of a rig setup in case of Rigged Camera
  25054. */
  25055. readonly rightCamera: Nullable<FreeCamera>;
  25056. /**
  25057. * Gets the left camera target of a rig setup in case of Rigged Camera
  25058. * @returns the target position
  25059. */
  25060. getLeftTarget(): Nullable<Vector3>;
  25061. /**
  25062. * Gets the right camera target of a rig setup in case of Rigged Camera
  25063. * @returns the target position
  25064. */
  25065. getRightTarget(): Nullable<Vector3>;
  25066. /**
  25067. * @hidden
  25068. */
  25069. setCameraRigMode(mode: number, rigParams: any): void;
  25070. /** @hidden */
  25071. static _setStereoscopicRigMode(camera: Camera): void;
  25072. /** @hidden */
  25073. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25074. /** @hidden */
  25075. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25076. /** @hidden */
  25077. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25078. /** @hidden */
  25079. _getVRProjectionMatrix(): Matrix;
  25080. protected _updateCameraRotationMatrix(): void;
  25081. protected _updateWebVRCameraRotationMatrix(): void;
  25082. /**
  25083. * This function MUST be overwritten by the different WebVR cameras available.
  25084. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25085. * @hidden
  25086. */
  25087. _getWebVRProjectionMatrix(): Matrix;
  25088. /**
  25089. * This function MUST be overwritten by the different WebVR cameras available.
  25090. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25091. * @hidden
  25092. */
  25093. _getWebVRViewMatrix(): Matrix;
  25094. /** @hidden */
  25095. setCameraRigParameter(name: string, value: any): void;
  25096. /**
  25097. * needs to be overridden by children so sub has required properties to be copied
  25098. * @hidden
  25099. */
  25100. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25101. /**
  25102. * May need to be overridden by children
  25103. * @hidden
  25104. */
  25105. _updateRigCameras(): void;
  25106. /** @hidden */
  25107. _setupInputs(): void;
  25108. /**
  25109. * Serialiaze the camera setup to a json represention
  25110. * @returns the JSON representation
  25111. */
  25112. serialize(): any;
  25113. /**
  25114. * Clones the current camera.
  25115. * @param name The cloned camera name
  25116. * @returns the cloned camera
  25117. */
  25118. clone(name: string): Camera;
  25119. /**
  25120. * Gets the direction of the camera relative to a given local axis.
  25121. * @param localAxis Defines the reference axis to provide a relative direction.
  25122. * @return the direction
  25123. */
  25124. getDirection(localAxis: Vector3): Vector3;
  25125. /**
  25126. * Returns the current camera absolute rotation
  25127. */
  25128. readonly absoluteRotation: Quaternion;
  25129. /**
  25130. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25131. * @param localAxis Defines the reference axis to provide a relative direction.
  25132. * @param result Defines the vector to store the result in
  25133. */
  25134. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25135. /**
  25136. * Gets a camera constructor for a given camera type
  25137. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25138. * @param name The name of the camera the result will be able to instantiate
  25139. * @param scene The scene the result will construct the camera in
  25140. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25141. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25142. * @returns a factory method to construc the camera
  25143. */
  25144. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25145. /**
  25146. * Compute the world matrix of the camera.
  25147. * @returns the camera workd matrix
  25148. */
  25149. computeWorldMatrix(): Matrix;
  25150. /**
  25151. * Parse a JSON and creates the camera from the parsed information
  25152. * @param parsedCamera The JSON to parse
  25153. * @param scene The scene to instantiate the camera in
  25154. * @returns the newly constructed camera
  25155. */
  25156. static Parse(parsedCamera: any, scene: Scene): Camera;
  25157. }
  25158. }
  25159. declare module BABYLON {
  25160. /**
  25161. * Class containing static functions to help procedurally build meshes
  25162. */
  25163. export class DiscBuilder {
  25164. /**
  25165. * Creates a plane polygonal mesh. By default, this is a disc
  25166. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25167. * * 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
  25168. * * 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
  25169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25170. * * 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
  25171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25172. * @param name defines the name of the mesh
  25173. * @param options defines the options used to create the mesh
  25174. * @param scene defines the hosting scene
  25175. * @returns the plane polygonal mesh
  25176. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25177. */
  25178. static CreateDisc(name: string, options: {
  25179. radius?: number;
  25180. tessellation?: number;
  25181. arc?: number;
  25182. updatable?: boolean;
  25183. sideOrientation?: number;
  25184. frontUVs?: Vector4;
  25185. backUVs?: Vector4;
  25186. }, scene?: Nullable<Scene>): Mesh;
  25187. }
  25188. }
  25189. declare module BABYLON {
  25190. /**
  25191. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25192. *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.
  25193. * The SPS is also a particle system. It provides some methods to manage the particles.
  25194. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25195. *
  25196. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25197. */
  25198. export class SolidParticleSystem implements IDisposable {
  25199. /**
  25200. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25201. * Example : var p = SPS.particles[i];
  25202. */
  25203. particles: SolidParticle[];
  25204. /**
  25205. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25206. */
  25207. nbParticles: number;
  25208. /**
  25209. * If the particles must ever face the camera (default false). Useful for planar particles.
  25210. */
  25211. billboard: boolean;
  25212. /**
  25213. * Recompute normals when adding a shape
  25214. */
  25215. recomputeNormals: boolean;
  25216. /**
  25217. * This a counter ofr your own usage. It's not set by any SPS functions.
  25218. */
  25219. counter: number;
  25220. /**
  25221. * The SPS name. This name is also given to the underlying mesh.
  25222. */
  25223. name: string;
  25224. /**
  25225. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25226. */
  25227. mesh: Mesh;
  25228. /**
  25229. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25230. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25231. */
  25232. vars: any;
  25233. /**
  25234. * This array is populated when the SPS is set as 'pickable'.
  25235. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25236. * Each element of this array is an object `{idx: int, faceId: int}`.
  25237. * `idx` is the picked particle index in the `SPS.particles` array
  25238. * `faceId` is the picked face index counted within this particle.
  25239. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25240. */
  25241. pickedParticles: {
  25242. idx: number;
  25243. faceId: number;
  25244. }[];
  25245. /**
  25246. * This array is populated when `enableDepthSort` is set to true.
  25247. * Each element of this array is an instance of the class DepthSortedParticle.
  25248. */
  25249. depthSortedParticles: DepthSortedParticle[];
  25250. /**
  25251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25252. * @hidden
  25253. */
  25254. _bSphereOnly: boolean;
  25255. /**
  25256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25257. * @hidden
  25258. */
  25259. _bSphereRadiusFactor: number;
  25260. private _scene;
  25261. private _positions;
  25262. private _indices;
  25263. private _normals;
  25264. private _colors;
  25265. private _uvs;
  25266. private _indices32;
  25267. private _positions32;
  25268. private _normals32;
  25269. private _fixedNormal32;
  25270. private _colors32;
  25271. private _uvs32;
  25272. private _index;
  25273. private _updatable;
  25274. private _pickable;
  25275. private _isVisibilityBoxLocked;
  25276. private _alwaysVisible;
  25277. private _depthSort;
  25278. private _shapeCounter;
  25279. private _copy;
  25280. private _color;
  25281. private _computeParticleColor;
  25282. private _computeParticleTexture;
  25283. private _computeParticleRotation;
  25284. private _computeParticleVertex;
  25285. private _computeBoundingBox;
  25286. private _depthSortParticles;
  25287. private _camera;
  25288. private _mustUnrotateFixedNormals;
  25289. private _particlesIntersect;
  25290. private _needs32Bits;
  25291. /**
  25292. * Creates a SPS (Solid Particle System) object.
  25293. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25294. * @param scene (Scene) is the scene in which the SPS is added.
  25295. * @param options defines the options of the sps e.g.
  25296. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25297. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25298. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25299. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25300. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25301. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25302. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25303. */
  25304. constructor(name: string, scene: Scene, options?: {
  25305. updatable?: boolean;
  25306. isPickable?: boolean;
  25307. enableDepthSort?: boolean;
  25308. particleIntersection?: boolean;
  25309. boundingSphereOnly?: boolean;
  25310. bSphereRadiusFactor?: number;
  25311. });
  25312. /**
  25313. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25314. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25315. * @returns the created mesh
  25316. */
  25317. buildMesh(): Mesh;
  25318. /**
  25319. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25320. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25321. * Thus the particles generated from `digest()` have their property `position` set yet.
  25322. * @param mesh ( Mesh ) is the mesh to be digested
  25323. * @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
  25324. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25325. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25326. * @returns the current SPS
  25327. */
  25328. digest(mesh: Mesh, options?: {
  25329. facetNb?: number;
  25330. number?: number;
  25331. delta?: number;
  25332. }): SolidParticleSystem;
  25333. private _unrotateFixedNormals;
  25334. private _resetCopy;
  25335. private _meshBuilder;
  25336. private _posToShape;
  25337. private _uvsToShapeUV;
  25338. private _addParticle;
  25339. /**
  25340. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25341. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25342. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25343. * @param nb (positive integer) the number of particles to be created from this model
  25344. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25345. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25346. * @returns the number of shapes in the system
  25347. */
  25348. addShape(mesh: Mesh, nb: number, options?: {
  25349. positionFunction?: any;
  25350. vertexFunction?: any;
  25351. }): number;
  25352. private _rebuildParticle;
  25353. /**
  25354. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25355. * @returns the SPS.
  25356. */
  25357. rebuildMesh(): SolidParticleSystem;
  25358. /**
  25359. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25360. * This method calls `updateParticle()` for each particle of the SPS.
  25361. * For an animated SPS, it is usually called within the render loop.
  25362. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25363. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25364. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25365. * @returns the SPS.
  25366. */
  25367. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25368. /**
  25369. * Disposes the SPS.
  25370. */
  25371. dispose(): void;
  25372. /**
  25373. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25374. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25375. * @returns the SPS.
  25376. */
  25377. refreshVisibleSize(): SolidParticleSystem;
  25378. /**
  25379. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25380. * @param size the size (float) of the visibility box
  25381. * note : this doesn't lock the SPS mesh bounding box.
  25382. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25383. */
  25384. setVisibilityBox(size: number): void;
  25385. /**
  25386. * Gets whether the SPS as always visible or not
  25387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25388. */
  25389. /**
  25390. * Sets the SPS as always visible or not
  25391. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25392. */
  25393. isAlwaysVisible: boolean;
  25394. /**
  25395. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25396. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25397. */
  25398. /**
  25399. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25400. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25401. */
  25402. isVisibilityBoxLocked: boolean;
  25403. /**
  25404. * Tells to `setParticles()` to compute the particle rotations or not.
  25405. * Default value : true. The SPS is faster when it's set to false.
  25406. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25407. */
  25408. /**
  25409. * Gets if `setParticles()` computes the particle rotations or not.
  25410. * Default value : true. The SPS is faster when it's set to false.
  25411. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25412. */
  25413. computeParticleRotation: boolean;
  25414. /**
  25415. * Tells to `setParticles()` to compute the particle colors or not.
  25416. * Default value : true. The SPS is faster when it's set to false.
  25417. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25418. */
  25419. /**
  25420. * Gets if `setParticles()` computes the particle colors or not.
  25421. * Default value : true. The SPS is faster when it's set to false.
  25422. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25423. */
  25424. computeParticleColor: boolean;
  25425. /**
  25426. * Gets if `setParticles()` computes the particle textures or not.
  25427. * Default value : true. The SPS is faster when it's set to false.
  25428. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25429. */
  25430. computeParticleTexture: boolean;
  25431. /**
  25432. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25433. * Default value : false. The SPS is faster when it's set to false.
  25434. * Note : the particle custom vertex positions aren't stored values.
  25435. */
  25436. /**
  25437. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25438. * Default value : false. The SPS is faster when it's set to false.
  25439. * Note : the particle custom vertex positions aren't stored values.
  25440. */
  25441. computeParticleVertex: boolean;
  25442. /**
  25443. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25444. */
  25445. /**
  25446. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25447. */
  25448. computeBoundingBox: boolean;
  25449. /**
  25450. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25451. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25452. * Default : `true`
  25453. */
  25454. /**
  25455. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25456. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25457. * Default : `true`
  25458. */
  25459. depthSortParticles: boolean;
  25460. /**
  25461. * This function does nothing. It may be overwritten to set all the particle first values.
  25462. * The SPS doesn't call this function, you may have to call it by your own.
  25463. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25464. */
  25465. initParticles(): void;
  25466. /**
  25467. * This function does nothing. It may be overwritten to recycle a particle.
  25468. * The SPS doesn't call this function, you may have to call it by your own.
  25469. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25470. * @param particle The particle to recycle
  25471. * @returns the recycled particle
  25472. */
  25473. recycleParticle(particle: SolidParticle): SolidParticle;
  25474. /**
  25475. * Updates a particle : this function should be overwritten by the user.
  25476. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25477. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25478. * @example : just set a particle position or velocity and recycle conditions
  25479. * @param particle The particle to update
  25480. * @returns the updated particle
  25481. */
  25482. updateParticle(particle: SolidParticle): SolidParticle;
  25483. /**
  25484. * Updates a vertex of a particle : it can be overwritten by the user.
  25485. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25486. * @param particle the current particle
  25487. * @param vertex the current index of the current particle
  25488. * @param pt the index of the current vertex in the particle shape
  25489. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25490. * @example : just set a vertex particle position
  25491. * @returns the updated vertex
  25492. */
  25493. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25494. /**
  25495. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25496. * This does nothing and may be overwritten by the user.
  25497. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25498. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25499. * @param update the boolean update value actually passed to setParticles()
  25500. */
  25501. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25502. /**
  25503. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25504. * This will be passed three parameters.
  25505. * This does nothing and may be overwritten by the user.
  25506. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25507. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25508. * @param update the boolean update value actually passed to setParticles()
  25509. */
  25510. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25511. }
  25512. }
  25513. declare module BABYLON {
  25514. /**
  25515. * Represents one particle of a solid particle system.
  25516. */
  25517. export class SolidParticle {
  25518. /**
  25519. * particle global index
  25520. */
  25521. idx: number;
  25522. /**
  25523. * The color of the particle
  25524. */
  25525. color: Nullable<Color4>;
  25526. /**
  25527. * The world space position of the particle.
  25528. */
  25529. position: Vector3;
  25530. /**
  25531. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25532. */
  25533. rotation: Vector3;
  25534. /**
  25535. * The world space rotation quaternion of the particle.
  25536. */
  25537. rotationQuaternion: Nullable<Quaternion>;
  25538. /**
  25539. * The scaling of the particle.
  25540. */
  25541. scaling: Vector3;
  25542. /**
  25543. * The uvs of the particle.
  25544. */
  25545. uvs: Vector4;
  25546. /**
  25547. * The current speed of the particle.
  25548. */
  25549. velocity: Vector3;
  25550. /**
  25551. * The pivot point in the particle local space.
  25552. */
  25553. pivot: Vector3;
  25554. /**
  25555. * Must the particle be translated from its pivot point in its local space ?
  25556. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25557. * Default : false
  25558. */
  25559. translateFromPivot: boolean;
  25560. /**
  25561. * Is the particle active or not ?
  25562. */
  25563. alive: boolean;
  25564. /**
  25565. * Is the particle visible or not ?
  25566. */
  25567. isVisible: boolean;
  25568. /**
  25569. * Index of this particle in the global "positions" array (Internal use)
  25570. * @hidden
  25571. */
  25572. _pos: number;
  25573. /**
  25574. * @hidden Index of this particle in the global "indices" array (Internal use)
  25575. */
  25576. _ind: number;
  25577. /**
  25578. * @hidden ModelShape of this particle (Internal use)
  25579. */
  25580. _model: ModelShape;
  25581. /**
  25582. * ModelShape id of this particle
  25583. */
  25584. shapeId: number;
  25585. /**
  25586. * Index of the particle in its shape id
  25587. */
  25588. idxInShape: number;
  25589. /**
  25590. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25591. */
  25592. _modelBoundingInfo: BoundingInfo;
  25593. /**
  25594. * @hidden Particle BoundingInfo object (Internal use)
  25595. */
  25596. _boundingInfo: BoundingInfo;
  25597. /**
  25598. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25599. */
  25600. _sps: SolidParticleSystem;
  25601. /**
  25602. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25603. */
  25604. _stillInvisible: boolean;
  25605. /**
  25606. * @hidden Last computed particle rotation matrix
  25607. */
  25608. _rotationMatrix: number[];
  25609. /**
  25610. * Parent particle Id, if any.
  25611. * Default null.
  25612. */
  25613. parentId: Nullable<number>;
  25614. /**
  25615. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25616. * The possible values are :
  25617. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25618. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25619. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25620. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25621. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25622. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25623. * */
  25624. cullingStrategy: number;
  25625. /**
  25626. * @hidden Internal global position in the SPS.
  25627. */
  25628. _globalPosition: Vector3;
  25629. /**
  25630. * Creates a Solid Particle object.
  25631. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25632. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25633. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25634. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25635. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25636. * @param shapeId (integer) is the model shape identifier in the SPS.
  25637. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25638. * @param sps defines the sps it is associated to
  25639. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25640. */
  25641. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25642. /**
  25643. * Legacy support, changed scale to scaling
  25644. */
  25645. /**
  25646. * Legacy support, changed scale to scaling
  25647. */
  25648. scale: Vector3;
  25649. /**
  25650. * Legacy support, changed quaternion to rotationQuaternion
  25651. */
  25652. /**
  25653. * Legacy support, changed quaternion to rotationQuaternion
  25654. */
  25655. quaternion: Nullable<Quaternion>;
  25656. /**
  25657. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25658. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25659. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25660. * @returns true if it intersects
  25661. */
  25662. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25663. /**
  25664. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25665. * A particle is in the frustum if its bounding box intersects the frustum
  25666. * @param frustumPlanes defines the frustum to test
  25667. * @returns true if the particle is in the frustum planes
  25668. */
  25669. isInFrustum(frustumPlanes: Plane[]): boolean;
  25670. /**
  25671. * get the rotation matrix of the particle
  25672. * @hidden
  25673. */
  25674. getRotationMatrix(m: Matrix): void;
  25675. }
  25676. /**
  25677. * Represents the shape of the model used by one particle of a solid particle system.
  25678. * SPS internal tool, don't use it manually.
  25679. */
  25680. export class ModelShape {
  25681. /**
  25682. * The shape id
  25683. * @hidden
  25684. */
  25685. shapeID: number;
  25686. /**
  25687. * flat array of model positions (internal use)
  25688. * @hidden
  25689. */
  25690. _shape: Vector3[];
  25691. /**
  25692. * flat array of model UVs (internal use)
  25693. * @hidden
  25694. */
  25695. _shapeUV: number[];
  25696. /**
  25697. * length of the shape in the model indices array (internal use)
  25698. * @hidden
  25699. */
  25700. _indicesLength: number;
  25701. /**
  25702. * Custom position function (internal use)
  25703. * @hidden
  25704. */
  25705. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25706. /**
  25707. * Custom vertex function (internal use)
  25708. * @hidden
  25709. */
  25710. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25711. /**
  25712. * 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.
  25713. * SPS internal tool, don't use it manually.
  25714. * @hidden
  25715. */
  25716. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25717. }
  25718. /**
  25719. * Represents a Depth Sorted Particle in the solid particle system.
  25720. */
  25721. export class DepthSortedParticle {
  25722. /**
  25723. * Index of the particle in the "indices" array
  25724. */
  25725. ind: number;
  25726. /**
  25727. * Length of the particle shape in the "indices" array
  25728. */
  25729. indicesLength: number;
  25730. /**
  25731. * Squared distance from the particle to the camera
  25732. */
  25733. sqDistance: number;
  25734. }
  25735. }
  25736. declare module BABYLON {
  25737. /**
  25738. * @hidden
  25739. */
  25740. export class _MeshCollisionData {
  25741. _checkCollisions: boolean;
  25742. _collisionMask: number;
  25743. _collisionGroup: number;
  25744. _collider: Nullable<Collider>;
  25745. _oldPositionForCollisions: Vector3;
  25746. _diffPositionForCollisions: Vector3;
  25747. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25748. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25749. }
  25750. }
  25751. declare module BABYLON {
  25752. /** @hidden */
  25753. class _FacetDataStorage {
  25754. facetPositions: Vector3[];
  25755. facetNormals: Vector3[];
  25756. facetPartitioning: number[][];
  25757. facetNb: number;
  25758. partitioningSubdivisions: number;
  25759. partitioningBBoxRatio: number;
  25760. facetDataEnabled: boolean;
  25761. facetParameters: any;
  25762. bbSize: Vector3;
  25763. subDiv: {
  25764. max: number;
  25765. X: number;
  25766. Y: number;
  25767. Z: number;
  25768. };
  25769. facetDepthSort: boolean;
  25770. facetDepthSortEnabled: boolean;
  25771. depthSortedIndices: IndicesArray;
  25772. depthSortedFacets: {
  25773. ind: number;
  25774. sqDistance: number;
  25775. }[];
  25776. facetDepthSortFunction: (f1: {
  25777. ind: number;
  25778. sqDistance: number;
  25779. }, f2: {
  25780. ind: number;
  25781. sqDistance: number;
  25782. }) => number;
  25783. facetDepthSortFrom: Vector3;
  25784. facetDepthSortOrigin: Vector3;
  25785. invertedMatrix: Matrix;
  25786. }
  25787. /**
  25788. * @hidden
  25789. **/
  25790. class _InternalAbstractMeshDataInfo {
  25791. _hasVertexAlpha: boolean;
  25792. _useVertexColors: boolean;
  25793. _numBoneInfluencers: number;
  25794. _applyFog: boolean;
  25795. _receiveShadows: boolean;
  25796. _facetData: _FacetDataStorage;
  25797. _visibility: number;
  25798. _skeleton: Nullable<Skeleton>;
  25799. _layerMask: number;
  25800. _computeBonesUsingShaders: boolean;
  25801. _isActive: boolean;
  25802. _onlyForInstances: boolean;
  25803. _isActiveIntermediate: boolean;
  25804. _onlyForInstancesIntermediate: boolean;
  25805. }
  25806. /**
  25807. * Class used to store all common mesh properties
  25808. */
  25809. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25810. /** No occlusion */
  25811. static OCCLUSION_TYPE_NONE: number;
  25812. /** Occlusion set to optimisitic */
  25813. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25814. /** Occlusion set to strict */
  25815. static OCCLUSION_TYPE_STRICT: number;
  25816. /** Use an accurante occlusion algorithm */
  25817. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25818. /** Use a conservative occlusion algorithm */
  25819. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25820. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25821. * Test order :
  25822. * Is the bounding sphere outside the frustum ?
  25823. * If not, are the bounding box vertices outside the frustum ?
  25824. * It not, then the cullable object is in the frustum.
  25825. */
  25826. static readonly CULLINGSTRATEGY_STANDARD: number;
  25827. /** Culling strategy : Bounding Sphere Only.
  25828. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25829. * It's also less accurate than the standard because some not visible objects can still be selected.
  25830. * Test : is the bounding sphere outside the frustum ?
  25831. * If not, then the cullable object is in the frustum.
  25832. */
  25833. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25834. /** Culling strategy : Optimistic Inclusion.
  25835. * This in an inclusion test first, then the standard exclusion test.
  25836. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25837. * 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.
  25838. * Anyway, it's as accurate as the standard strategy.
  25839. * Test :
  25840. * Is the cullable object bounding sphere center in the frustum ?
  25841. * If not, apply the default culling strategy.
  25842. */
  25843. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25844. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25845. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25846. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25847. * 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.
  25848. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25849. * Test :
  25850. * Is the cullable object bounding sphere center in the frustum ?
  25851. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25852. */
  25853. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25854. /**
  25855. * No billboard
  25856. */
  25857. static readonly BILLBOARDMODE_NONE: number;
  25858. /** Billboard on X axis */
  25859. static readonly BILLBOARDMODE_X: number;
  25860. /** Billboard on Y axis */
  25861. static readonly BILLBOARDMODE_Y: number;
  25862. /** Billboard on Z axis */
  25863. static readonly BILLBOARDMODE_Z: number;
  25864. /** Billboard on all axes */
  25865. static readonly BILLBOARDMODE_ALL: number;
  25866. /** Billboard on using position instead of orientation */
  25867. static readonly BILLBOARDMODE_USE_POSITION: number;
  25868. /** @hidden */
  25869. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25870. /**
  25871. * The culling strategy to use to check whether the mesh must be rendered or not.
  25872. * This value can be changed at any time and will be used on the next render mesh selection.
  25873. * The possible values are :
  25874. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25875. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25876. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25877. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25878. * Please read each static variable documentation to get details about the culling process.
  25879. * */
  25880. cullingStrategy: number;
  25881. /**
  25882. * Gets the number of facets in the mesh
  25883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25884. */
  25885. readonly facetNb: number;
  25886. /**
  25887. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25889. */
  25890. partitioningSubdivisions: number;
  25891. /**
  25892. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25893. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25895. */
  25896. partitioningBBoxRatio: number;
  25897. /**
  25898. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25899. * Works only for updatable meshes.
  25900. * Doesn't work with multi-materials
  25901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25902. */
  25903. mustDepthSortFacets: boolean;
  25904. /**
  25905. * The location (Vector3) where the facet depth sort must be computed from.
  25906. * By default, the active camera position.
  25907. * Used only when facet depth sort is enabled
  25908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25909. */
  25910. facetDepthSortFrom: Vector3;
  25911. /**
  25912. * gets a boolean indicating if facetData is enabled
  25913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25914. */
  25915. readonly isFacetDataEnabled: boolean;
  25916. /** @hidden */
  25917. _updateNonUniformScalingState(value: boolean): boolean;
  25918. /**
  25919. * An event triggered when this mesh collides with another one
  25920. */
  25921. onCollideObservable: Observable<AbstractMesh>;
  25922. /** Set a function to call when this mesh collides with another one */
  25923. onCollide: () => void;
  25924. /**
  25925. * An event triggered when the collision's position changes
  25926. */
  25927. onCollisionPositionChangeObservable: Observable<Vector3>;
  25928. /** Set a function to call when the collision's position changes */
  25929. onCollisionPositionChange: () => void;
  25930. /**
  25931. * An event triggered when material is changed
  25932. */
  25933. onMaterialChangedObservable: Observable<AbstractMesh>;
  25934. /**
  25935. * Gets or sets the orientation for POV movement & rotation
  25936. */
  25937. definedFacingForward: boolean;
  25938. /** @hidden */
  25939. _occlusionQuery: Nullable<WebGLQuery>;
  25940. /** @hidden */
  25941. _renderingGroup: Nullable<RenderingGroup>;
  25942. /**
  25943. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25944. */
  25945. /**
  25946. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25947. */
  25948. visibility: number;
  25949. /** Gets or sets the alpha index used to sort transparent meshes
  25950. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25951. */
  25952. alphaIndex: number;
  25953. /**
  25954. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25955. */
  25956. isVisible: boolean;
  25957. /**
  25958. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25959. */
  25960. isPickable: boolean;
  25961. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25962. showSubMeshesBoundingBox: boolean;
  25963. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25965. */
  25966. isBlocker: boolean;
  25967. /**
  25968. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25969. */
  25970. enablePointerMoveEvents: boolean;
  25971. /**
  25972. * Specifies the rendering group id for this mesh (0 by default)
  25973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25974. */
  25975. renderingGroupId: number;
  25976. private _material;
  25977. /** Gets or sets current material */
  25978. material: Nullable<Material>;
  25979. /**
  25980. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25981. * @see http://doc.babylonjs.com/babylon101/shadows
  25982. */
  25983. receiveShadows: boolean;
  25984. /** Defines color to use when rendering outline */
  25985. outlineColor: Color3;
  25986. /** Define width to use when rendering outline */
  25987. outlineWidth: number;
  25988. /** Defines color to use when rendering overlay */
  25989. overlayColor: Color3;
  25990. /** Defines alpha to use when rendering overlay */
  25991. overlayAlpha: number;
  25992. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25993. hasVertexAlpha: boolean;
  25994. /** 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) */
  25995. useVertexColors: boolean;
  25996. /**
  25997. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25998. */
  25999. computeBonesUsingShaders: boolean;
  26000. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26001. numBoneInfluencers: number;
  26002. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26003. applyFog: boolean;
  26004. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26005. useOctreeForRenderingSelection: boolean;
  26006. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26007. useOctreeForPicking: boolean;
  26008. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26009. useOctreeForCollisions: boolean;
  26010. /**
  26011. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26012. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26013. */
  26014. layerMask: number;
  26015. /**
  26016. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26017. */
  26018. alwaysSelectAsActiveMesh: boolean;
  26019. /**
  26020. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26021. */
  26022. doNotSyncBoundingInfo: boolean;
  26023. /**
  26024. * Gets or sets the current action manager
  26025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26026. */
  26027. actionManager: Nullable<AbstractActionManager>;
  26028. private _meshCollisionData;
  26029. /**
  26030. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26032. */
  26033. ellipsoid: Vector3;
  26034. /**
  26035. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26036. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26037. */
  26038. ellipsoidOffset: Vector3;
  26039. /**
  26040. * Gets or sets a collision mask used to mask collisions (default is -1).
  26041. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26042. */
  26043. collisionMask: number;
  26044. /**
  26045. * Gets or sets the current collision group mask (-1 by default).
  26046. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26047. */
  26048. collisionGroup: number;
  26049. /**
  26050. * Defines edge width used when edgesRenderer is enabled
  26051. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26052. */
  26053. edgesWidth: number;
  26054. /**
  26055. * Defines edge color used when edgesRenderer is enabled
  26056. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26057. */
  26058. edgesColor: Color4;
  26059. /** @hidden */
  26060. _edgesRenderer: Nullable<IEdgesRenderer>;
  26061. /** @hidden */
  26062. _masterMesh: Nullable<AbstractMesh>;
  26063. /** @hidden */
  26064. _boundingInfo: Nullable<BoundingInfo>;
  26065. /** @hidden */
  26066. _renderId: number;
  26067. /**
  26068. * Gets or sets the list of subMeshes
  26069. * @see http://doc.babylonjs.com/how_to/multi_materials
  26070. */
  26071. subMeshes: SubMesh[];
  26072. /** @hidden */
  26073. _intersectionsInProgress: AbstractMesh[];
  26074. /** @hidden */
  26075. _unIndexed: boolean;
  26076. /** @hidden */
  26077. _lightSources: Light[];
  26078. /** Gets the list of lights affecting that mesh */
  26079. readonly lightSources: Light[];
  26080. /** @hidden */
  26081. readonly _positions: Nullable<Vector3[]>;
  26082. /** @hidden */
  26083. _waitingData: {
  26084. lods: Nullable<any>;
  26085. actions: Nullable<any>;
  26086. freezeWorldMatrix: Nullable<boolean>;
  26087. };
  26088. /** @hidden */
  26089. _bonesTransformMatrices: Nullable<Float32Array>;
  26090. /** @hidden */
  26091. _transformMatrixTexture: Nullable<RawTexture>;
  26092. /**
  26093. * Gets or sets a skeleton to apply skining transformations
  26094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26095. */
  26096. skeleton: Nullable<Skeleton>;
  26097. /**
  26098. * An event triggered when the mesh is rebuilt.
  26099. */
  26100. onRebuildObservable: Observable<AbstractMesh>;
  26101. /**
  26102. * Creates a new AbstractMesh
  26103. * @param name defines the name of the mesh
  26104. * @param scene defines the hosting scene
  26105. */
  26106. constructor(name: string, scene?: Nullable<Scene>);
  26107. /**
  26108. * Returns the string "AbstractMesh"
  26109. * @returns "AbstractMesh"
  26110. */
  26111. getClassName(): string;
  26112. /**
  26113. * Gets a string representation of the current mesh
  26114. * @param fullDetails defines a boolean indicating if full details must be included
  26115. * @returns a string representation of the current mesh
  26116. */
  26117. toString(fullDetails?: boolean): string;
  26118. /**
  26119. * @hidden
  26120. */
  26121. protected _getEffectiveParent(): Nullable<Node>;
  26122. /** @hidden */
  26123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26124. /** @hidden */
  26125. _rebuild(): void;
  26126. /** @hidden */
  26127. _resyncLightSources(): void;
  26128. /** @hidden */
  26129. _resyncLighSource(light: Light): void;
  26130. /** @hidden */
  26131. _unBindEffect(): void;
  26132. /** @hidden */
  26133. _removeLightSource(light: Light, dispose: boolean): void;
  26134. private _markSubMeshesAsDirty;
  26135. /** @hidden */
  26136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26137. /** @hidden */
  26138. _markSubMeshesAsAttributesDirty(): void;
  26139. /** @hidden */
  26140. _markSubMeshesAsMiscDirty(): void;
  26141. /**
  26142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26143. */
  26144. scaling: Vector3;
  26145. /**
  26146. * Returns true if the mesh is blocked. Implemented by child classes
  26147. */
  26148. readonly isBlocked: boolean;
  26149. /**
  26150. * Returns the mesh itself by default. Implemented by child classes
  26151. * @param camera defines the camera to use to pick the right LOD level
  26152. * @returns the currentAbstractMesh
  26153. */
  26154. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26155. /**
  26156. * Returns 0 by default. Implemented by child classes
  26157. * @returns an integer
  26158. */
  26159. getTotalVertices(): number;
  26160. /**
  26161. * Returns a positive integer : the total number of indices in this mesh geometry.
  26162. * @returns the numner of indices or zero if the mesh has no geometry.
  26163. */
  26164. getTotalIndices(): number;
  26165. /**
  26166. * Returns null by default. Implemented by child classes
  26167. * @returns null
  26168. */
  26169. getIndices(): Nullable<IndicesArray>;
  26170. /**
  26171. * Returns the array of the requested vertex data kind. Implemented by child classes
  26172. * @param kind defines the vertex data kind to use
  26173. * @returns null
  26174. */
  26175. getVerticesData(kind: string): Nullable<FloatArray>;
  26176. /**
  26177. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26178. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26179. * Note that a new underlying VertexBuffer object is created each call.
  26180. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26181. * @param kind defines vertex data kind:
  26182. * * VertexBuffer.PositionKind
  26183. * * VertexBuffer.UVKind
  26184. * * VertexBuffer.UV2Kind
  26185. * * VertexBuffer.UV3Kind
  26186. * * VertexBuffer.UV4Kind
  26187. * * VertexBuffer.UV5Kind
  26188. * * VertexBuffer.UV6Kind
  26189. * * VertexBuffer.ColorKind
  26190. * * VertexBuffer.MatricesIndicesKind
  26191. * * VertexBuffer.MatricesIndicesExtraKind
  26192. * * VertexBuffer.MatricesWeightsKind
  26193. * * VertexBuffer.MatricesWeightsExtraKind
  26194. * @param data defines the data source
  26195. * @param updatable defines if the data must be flagged as updatable (or static)
  26196. * @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
  26197. * @returns the current mesh
  26198. */
  26199. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26200. /**
  26201. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26202. * If the mesh has no geometry, it is simply returned as it is.
  26203. * @param kind defines vertex data kind:
  26204. * * VertexBuffer.PositionKind
  26205. * * VertexBuffer.UVKind
  26206. * * VertexBuffer.UV2Kind
  26207. * * VertexBuffer.UV3Kind
  26208. * * VertexBuffer.UV4Kind
  26209. * * VertexBuffer.UV5Kind
  26210. * * VertexBuffer.UV6Kind
  26211. * * VertexBuffer.ColorKind
  26212. * * VertexBuffer.MatricesIndicesKind
  26213. * * VertexBuffer.MatricesIndicesExtraKind
  26214. * * VertexBuffer.MatricesWeightsKind
  26215. * * VertexBuffer.MatricesWeightsExtraKind
  26216. * @param data defines the data source
  26217. * @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
  26218. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26219. * @returns the current mesh
  26220. */
  26221. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26222. /**
  26223. * Sets the mesh indices,
  26224. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26225. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26226. * @param totalVertices Defines the total number of vertices
  26227. * @returns the current mesh
  26228. */
  26229. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26230. /**
  26231. * Gets a boolean indicating if specific vertex data is present
  26232. * @param kind defines the vertex data kind to use
  26233. * @returns true is data kind is present
  26234. */
  26235. isVerticesDataPresent(kind: string): boolean;
  26236. /**
  26237. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26238. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26239. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26240. * @returns a BoundingInfo
  26241. */
  26242. getBoundingInfo(): BoundingInfo;
  26243. /**
  26244. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26245. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26246. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26247. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26248. * @returns the current mesh
  26249. */
  26250. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26251. /**
  26252. * Overwrite the current bounding info
  26253. * @param boundingInfo defines the new bounding info
  26254. * @returns the current mesh
  26255. */
  26256. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26257. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26258. readonly useBones: boolean;
  26259. /** @hidden */
  26260. _preActivate(): void;
  26261. /** @hidden */
  26262. _preActivateForIntermediateRendering(renderId: number): void;
  26263. /** @hidden */
  26264. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26265. /** @hidden */
  26266. _postActivate(): void;
  26267. /** @hidden */
  26268. _freeze(): void;
  26269. /** @hidden */
  26270. _unFreeze(): void;
  26271. /**
  26272. * Gets the current world matrix
  26273. * @returns a Matrix
  26274. */
  26275. getWorldMatrix(): Matrix;
  26276. /** @hidden */
  26277. _getWorldMatrixDeterminant(): number;
  26278. /**
  26279. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26280. */
  26281. readonly isAnInstance: boolean;
  26282. /**
  26283. * Gets a boolean indicating if this mesh has instances
  26284. */
  26285. readonly hasInstances: boolean;
  26286. /**
  26287. * Perform relative position change from the point of view of behind the front of the mesh.
  26288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26289. * Supports definition of mesh facing forward or backward
  26290. * @param amountRight defines the distance on the right axis
  26291. * @param amountUp defines the distance on the up axis
  26292. * @param amountForward defines the distance on the forward axis
  26293. * @returns the current mesh
  26294. */
  26295. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26296. /**
  26297. * Calculate relative position change from the point of view of behind the front of the mesh.
  26298. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26299. * Supports definition of mesh facing forward or backward
  26300. * @param amountRight defines the distance on the right axis
  26301. * @param amountUp defines the distance on the up axis
  26302. * @param amountForward defines the distance on the forward axis
  26303. * @returns the new displacement vector
  26304. */
  26305. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26306. /**
  26307. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26308. * Supports definition of mesh facing forward or backward
  26309. * @param flipBack defines the flip
  26310. * @param twirlClockwise defines the twirl
  26311. * @param tiltRight defines the tilt
  26312. * @returns the current mesh
  26313. */
  26314. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26315. /**
  26316. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26317. * Supports definition of mesh facing forward or backward.
  26318. * @param flipBack defines the flip
  26319. * @param twirlClockwise defines the twirl
  26320. * @param tiltRight defines the tilt
  26321. * @returns the new rotation vector
  26322. */
  26323. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26324. /**
  26325. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26326. * This means the mesh underlying bounding box and sphere are recomputed.
  26327. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26328. * @returns the current mesh
  26329. */
  26330. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26331. /** @hidden */
  26332. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26333. /** @hidden */
  26334. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26335. /** @hidden */
  26336. _updateBoundingInfo(): AbstractMesh;
  26337. /** @hidden */
  26338. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26339. /** @hidden */
  26340. protected _afterComputeWorldMatrix(): void;
  26341. /** @hidden */
  26342. readonly _effectiveMesh: AbstractMesh;
  26343. /**
  26344. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26345. * A mesh is in the frustum if its bounding box intersects the frustum
  26346. * @param frustumPlanes defines the frustum to test
  26347. * @returns true if the mesh is in the frustum planes
  26348. */
  26349. isInFrustum(frustumPlanes: Plane[]): boolean;
  26350. /**
  26351. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26352. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26353. * @param frustumPlanes defines the frustum to test
  26354. * @returns true if the mesh is completely in the frustum planes
  26355. */
  26356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26357. /**
  26358. * True if the mesh intersects another mesh or a SolidParticle object
  26359. * @param mesh defines a target mesh or SolidParticle to test
  26360. * @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)
  26361. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26362. * @returns true if there is an intersection
  26363. */
  26364. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26365. /**
  26366. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26367. * @param point defines the point to test
  26368. * @returns true if there is an intersection
  26369. */
  26370. intersectsPoint(point: Vector3): boolean;
  26371. /**
  26372. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26374. */
  26375. checkCollisions: boolean;
  26376. /**
  26377. * Gets Collider object used to compute collisions (not physics)
  26378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26379. */
  26380. readonly collider: Nullable<Collider>;
  26381. /**
  26382. * Move the mesh using collision engine
  26383. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26384. * @param displacement defines the requested displacement vector
  26385. * @returns the current mesh
  26386. */
  26387. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26388. private _onCollisionPositionChange;
  26389. /** @hidden */
  26390. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26391. /** @hidden */
  26392. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26393. /** @hidden */
  26394. _checkCollision(collider: Collider): AbstractMesh;
  26395. /** @hidden */
  26396. _generatePointsArray(): boolean;
  26397. /**
  26398. * Checks if the passed Ray intersects with the mesh
  26399. * @param ray defines the ray to use
  26400. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26402. * @returns the picking info
  26403. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26404. */
  26405. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26406. /**
  26407. * Clones the current mesh
  26408. * @param name defines the mesh name
  26409. * @param newParent defines the new mesh parent
  26410. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26411. * @returns the new mesh
  26412. */
  26413. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26414. /**
  26415. * Disposes all the submeshes of the current meshnp
  26416. * @returns the current mesh
  26417. */
  26418. releaseSubMeshes(): AbstractMesh;
  26419. /**
  26420. * Releases resources associated with this abstract mesh.
  26421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26423. */
  26424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26425. /**
  26426. * Adds the passed mesh as a child to the current mesh
  26427. * @param mesh defines the child mesh
  26428. * @returns the current mesh
  26429. */
  26430. addChild(mesh: AbstractMesh): AbstractMesh;
  26431. /**
  26432. * Removes the passed mesh from the current mesh children list
  26433. * @param mesh defines the child mesh
  26434. * @returns the current mesh
  26435. */
  26436. removeChild(mesh: AbstractMesh): AbstractMesh;
  26437. /** @hidden */
  26438. private _initFacetData;
  26439. /**
  26440. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26441. * This method can be called within the render loop.
  26442. * 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
  26443. * @returns the current mesh
  26444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26445. */
  26446. updateFacetData(): AbstractMesh;
  26447. /**
  26448. * Returns the facetLocalNormals array.
  26449. * The normals are expressed in the mesh local spac
  26450. * @returns an array of Vector3
  26451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26452. */
  26453. getFacetLocalNormals(): Vector3[];
  26454. /**
  26455. * Returns the facetLocalPositions array.
  26456. * The facet positions are expressed in the mesh local space
  26457. * @returns an array of Vector3
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26459. */
  26460. getFacetLocalPositions(): Vector3[];
  26461. /**
  26462. * Returns the facetLocalPartioning array
  26463. * @returns an array of array of numbers
  26464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26465. */
  26466. getFacetLocalPartitioning(): number[][];
  26467. /**
  26468. * Returns the i-th facet position in the world system.
  26469. * This method allocates a new Vector3 per call
  26470. * @param i defines the facet index
  26471. * @returns a new Vector3
  26472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26473. */
  26474. getFacetPosition(i: number): Vector3;
  26475. /**
  26476. * Sets the reference Vector3 with the i-th facet position in the world system
  26477. * @param i defines the facet index
  26478. * @param ref defines the target vector
  26479. * @returns the current mesh
  26480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26481. */
  26482. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26483. /**
  26484. * Returns the i-th facet normal in the world system.
  26485. * This method allocates a new Vector3 per call
  26486. * @param i defines the facet index
  26487. * @returns a new Vector3
  26488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26489. */
  26490. getFacetNormal(i: number): Vector3;
  26491. /**
  26492. * Sets the reference Vector3 with the i-th facet normal in the world system
  26493. * @param i defines the facet index
  26494. * @param ref defines the target vector
  26495. * @returns the current mesh
  26496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26497. */
  26498. getFacetNormalToRef(i: number, ref: Vector3): this;
  26499. /**
  26500. * 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)
  26501. * @param x defines x coordinate
  26502. * @param y defines y coordinate
  26503. * @param z defines z coordinate
  26504. * @returns the array of facet indexes
  26505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26506. */
  26507. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26508. /**
  26509. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26510. * @param projected sets as the (x,y,z) world projection on the facet
  26511. * @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
  26512. * @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
  26513. * @param x defines x coordinate
  26514. * @param y defines y coordinate
  26515. * @param z defines z coordinate
  26516. * @returns the face index if found (or null instead)
  26517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26518. */
  26519. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26520. /**
  26521. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26522. * @param projected sets as the (x,y,z) local projection on the facet
  26523. * @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
  26524. * @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
  26525. * @param x defines x coordinate
  26526. * @param y defines y coordinate
  26527. * @param z defines z coordinate
  26528. * @returns the face index if found (or null instead)
  26529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26530. */
  26531. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26532. /**
  26533. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26534. * @returns the parameters
  26535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26536. */
  26537. getFacetDataParameters(): any;
  26538. /**
  26539. * Disables the feature FacetData and frees the related memory
  26540. * @returns the current mesh
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26542. */
  26543. disableFacetData(): AbstractMesh;
  26544. /**
  26545. * Updates the AbstractMesh indices array
  26546. * @param indices defines the data source
  26547. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26548. * @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)
  26549. * @returns the current mesh
  26550. */
  26551. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26552. /**
  26553. * Creates new normals data for the mesh
  26554. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26555. * @returns the current mesh
  26556. */
  26557. createNormals(updatable: boolean): AbstractMesh;
  26558. /**
  26559. * Align the mesh with a normal
  26560. * @param normal defines the normal to use
  26561. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26562. * @returns the current mesh
  26563. */
  26564. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26565. /** @hidden */
  26566. _checkOcclusionQuery(): boolean;
  26567. /**
  26568. * Disables the mesh edge rendering mode
  26569. * @returns the currentAbstractMesh
  26570. */
  26571. disableEdgesRendering(): AbstractMesh;
  26572. /**
  26573. * Enables the edge rendering mode on the mesh.
  26574. * This mode makes the mesh edges visible
  26575. * @param epsilon defines the maximal distance between two angles to detect a face
  26576. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26577. * @returns the currentAbstractMesh
  26578. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26579. */
  26580. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26581. }
  26582. }
  26583. declare module BABYLON {
  26584. /**
  26585. * Interface used to define ActionEvent
  26586. */
  26587. export interface IActionEvent {
  26588. /** The mesh or sprite that triggered the action */
  26589. source: any;
  26590. /** The X mouse cursor position at the time of the event */
  26591. pointerX: number;
  26592. /** The Y mouse cursor position at the time of the event */
  26593. pointerY: number;
  26594. /** The mesh that is currently pointed at (can be null) */
  26595. meshUnderPointer: Nullable<AbstractMesh>;
  26596. /** the original (browser) event that triggered the ActionEvent */
  26597. sourceEvent?: any;
  26598. /** additional data for the event */
  26599. additionalData?: any;
  26600. }
  26601. /**
  26602. * ActionEvent is the event being sent when an action is triggered.
  26603. */
  26604. export class ActionEvent implements IActionEvent {
  26605. /** The mesh or sprite that triggered the action */
  26606. source: any;
  26607. /** The X mouse cursor position at the time of the event */
  26608. pointerX: number;
  26609. /** The Y mouse cursor position at the time of the event */
  26610. pointerY: number;
  26611. /** The mesh that is currently pointed at (can be null) */
  26612. meshUnderPointer: Nullable<AbstractMesh>;
  26613. /** the original (browser) event that triggered the ActionEvent */
  26614. sourceEvent?: any;
  26615. /** additional data for the event */
  26616. additionalData?: any;
  26617. /**
  26618. * Creates a new ActionEvent
  26619. * @param source The mesh or sprite that triggered the action
  26620. * @param pointerX The X mouse cursor position at the time of the event
  26621. * @param pointerY The Y mouse cursor position at the time of the event
  26622. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26623. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26624. * @param additionalData additional data for the event
  26625. */
  26626. constructor(
  26627. /** The mesh or sprite that triggered the action */
  26628. source: any,
  26629. /** The X mouse cursor position at the time of the event */
  26630. pointerX: number,
  26631. /** The Y mouse cursor position at the time of the event */
  26632. pointerY: number,
  26633. /** The mesh that is currently pointed at (can be null) */
  26634. meshUnderPointer: Nullable<AbstractMesh>,
  26635. /** the original (browser) event that triggered the ActionEvent */
  26636. sourceEvent?: any,
  26637. /** additional data for the event */
  26638. additionalData?: any);
  26639. /**
  26640. * Helper function to auto-create an ActionEvent from a source mesh.
  26641. * @param source The source mesh that triggered the event
  26642. * @param evt The original (browser) event
  26643. * @param additionalData additional data for the event
  26644. * @returns the new ActionEvent
  26645. */
  26646. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26647. /**
  26648. * Helper function to auto-create an ActionEvent from a source sprite
  26649. * @param source The source sprite that triggered the event
  26650. * @param scene Scene associated with the sprite
  26651. * @param evt The original (browser) event
  26652. * @param additionalData additional data for the event
  26653. * @returns the new ActionEvent
  26654. */
  26655. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26656. /**
  26657. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26658. * @param scene the scene where the event occurred
  26659. * @param evt The original (browser) event
  26660. * @returns the new ActionEvent
  26661. */
  26662. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26663. /**
  26664. * Helper function to auto-create an ActionEvent from a primitive
  26665. * @param prim defines the target primitive
  26666. * @param pointerPos defines the pointer position
  26667. * @param evt The original (browser) event
  26668. * @param additionalData additional data for the event
  26669. * @returns the new ActionEvent
  26670. */
  26671. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26672. }
  26673. }
  26674. declare module BABYLON {
  26675. /**
  26676. * Abstract class used to decouple action Manager from scene and meshes.
  26677. * Do not instantiate.
  26678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26679. */
  26680. export abstract class AbstractActionManager implements IDisposable {
  26681. /** Gets the list of active triggers */
  26682. static Triggers: {
  26683. [key: string]: number;
  26684. };
  26685. /** Gets the cursor to use when hovering items */
  26686. hoverCursor: string;
  26687. /** Gets the list of actions */
  26688. actions: IAction[];
  26689. /**
  26690. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26691. */
  26692. isRecursive: boolean;
  26693. /**
  26694. * Releases all associated resources
  26695. */
  26696. abstract dispose(): void;
  26697. /**
  26698. * Does this action manager has pointer triggers
  26699. */
  26700. abstract readonly hasPointerTriggers: boolean;
  26701. /**
  26702. * Does this action manager has pick triggers
  26703. */
  26704. abstract readonly hasPickTriggers: boolean;
  26705. /**
  26706. * Process a specific trigger
  26707. * @param trigger defines the trigger to process
  26708. * @param evt defines the event details to be processed
  26709. */
  26710. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26711. /**
  26712. * Does this action manager handles actions of any of the given triggers
  26713. * @param triggers defines the triggers to be tested
  26714. * @return a boolean indicating whether one (or more) of the triggers is handled
  26715. */
  26716. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26717. /**
  26718. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26719. * speed.
  26720. * @param triggerA defines the trigger to be tested
  26721. * @param triggerB defines the trigger to be tested
  26722. * @return a boolean indicating whether one (or more) of the triggers is handled
  26723. */
  26724. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26725. /**
  26726. * Does this action manager handles actions of a given trigger
  26727. * @param trigger defines the trigger to be tested
  26728. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26729. * @return whether the trigger is handled
  26730. */
  26731. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26732. /**
  26733. * Serialize this manager to a JSON object
  26734. * @param name defines the property name to store this manager
  26735. * @returns a JSON representation of this manager
  26736. */
  26737. abstract serialize(name: string): any;
  26738. /**
  26739. * Registers an action to this action manager
  26740. * @param action defines the action to be registered
  26741. * @return the action amended (prepared) after registration
  26742. */
  26743. abstract registerAction(action: IAction): Nullable<IAction>;
  26744. /**
  26745. * Unregisters an action to this action manager
  26746. * @param action defines the action to be unregistered
  26747. * @return a boolean indicating whether the action has been unregistered
  26748. */
  26749. abstract unregisterAction(action: IAction): Boolean;
  26750. /**
  26751. * Does exist one action manager with at least one trigger
  26752. **/
  26753. static readonly HasTriggers: boolean;
  26754. /**
  26755. * Does exist one action manager with at least one pick trigger
  26756. **/
  26757. static readonly HasPickTriggers: boolean;
  26758. /**
  26759. * Does exist one action manager that handles actions of a given trigger
  26760. * @param trigger defines the trigger to be tested
  26761. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26762. **/
  26763. static HasSpecificTrigger(trigger: number): boolean;
  26764. }
  26765. }
  26766. declare module BABYLON {
  26767. /**
  26768. * Defines how a node can be built from a string name.
  26769. */
  26770. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26771. /**
  26772. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26773. */
  26774. export class Node implements IBehaviorAware<Node> {
  26775. /** @hidden */
  26776. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26777. private static _NodeConstructors;
  26778. /**
  26779. * Add a new node constructor
  26780. * @param type defines the type name of the node to construct
  26781. * @param constructorFunc defines the constructor function
  26782. */
  26783. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26784. /**
  26785. * Returns a node constructor based on type name
  26786. * @param type defines the type name
  26787. * @param name defines the new node name
  26788. * @param scene defines the hosting scene
  26789. * @param options defines optional options to transmit to constructors
  26790. * @returns the new constructor or null
  26791. */
  26792. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26793. /**
  26794. * Gets or sets the name of the node
  26795. */
  26796. name: string;
  26797. /**
  26798. * Gets or sets the id of the node
  26799. */
  26800. id: string;
  26801. /**
  26802. * Gets or sets the unique id of the node
  26803. */
  26804. uniqueId: number;
  26805. /**
  26806. * Gets or sets a string used to store user defined state for the node
  26807. */
  26808. state: string;
  26809. /**
  26810. * Gets or sets an object used to store user defined information for the node
  26811. */
  26812. metadata: any;
  26813. /**
  26814. * For internal use only. Please do not use.
  26815. */
  26816. reservedDataStore: any;
  26817. /**
  26818. * List of inspectable custom properties (used by the Inspector)
  26819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26820. */
  26821. inspectableCustomProperties: IInspectable[];
  26822. /**
  26823. * Gets or sets a boolean used to define if the node must be serialized
  26824. */
  26825. doNotSerialize: boolean;
  26826. /** @hidden */
  26827. _isDisposed: boolean;
  26828. /**
  26829. * Gets a list of Animations associated with the node
  26830. */
  26831. animations: Animation[];
  26832. protected _ranges: {
  26833. [name: string]: Nullable<AnimationRange>;
  26834. };
  26835. /**
  26836. * Callback raised when the node is ready to be used
  26837. */
  26838. onReady: Nullable<(node: Node) => void>;
  26839. private _isEnabled;
  26840. private _isParentEnabled;
  26841. private _isReady;
  26842. /** @hidden */
  26843. _currentRenderId: number;
  26844. private _parentUpdateId;
  26845. /** @hidden */
  26846. _childUpdateId: number;
  26847. /** @hidden */
  26848. _waitingParentId: Nullable<string>;
  26849. /** @hidden */
  26850. _scene: Scene;
  26851. /** @hidden */
  26852. _cache: any;
  26853. private _parentNode;
  26854. private _children;
  26855. /** @hidden */
  26856. _worldMatrix: Matrix;
  26857. /** @hidden */
  26858. _worldMatrixDeterminant: number;
  26859. /** @hidden */
  26860. _worldMatrixDeterminantIsDirty: boolean;
  26861. /** @hidden */
  26862. private _sceneRootNodesIndex;
  26863. /**
  26864. * Gets a boolean indicating if the node has been disposed
  26865. * @returns true if the node was disposed
  26866. */
  26867. isDisposed(): boolean;
  26868. /**
  26869. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26870. * @see https://doc.babylonjs.com/how_to/parenting
  26871. */
  26872. parent: Nullable<Node>;
  26873. private addToSceneRootNodes;
  26874. private removeFromSceneRootNodes;
  26875. private _animationPropertiesOverride;
  26876. /**
  26877. * Gets or sets the animation properties override
  26878. */
  26879. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26880. /**
  26881. * Gets a string idenfifying the name of the class
  26882. * @returns "Node" string
  26883. */
  26884. getClassName(): string;
  26885. /** @hidden */
  26886. readonly _isNode: boolean;
  26887. /**
  26888. * An event triggered when the mesh is disposed
  26889. */
  26890. onDisposeObservable: Observable<Node>;
  26891. private _onDisposeObserver;
  26892. /**
  26893. * Sets a callback that will be raised when the node will be disposed
  26894. */
  26895. onDispose: () => void;
  26896. /**
  26897. * Creates a new Node
  26898. * @param name the name and id to be given to this node
  26899. * @param scene the scene this node will be added to
  26900. * @param addToRootNodes the node will be added to scene.rootNodes
  26901. */
  26902. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26903. /**
  26904. * Gets the scene of the node
  26905. * @returns a scene
  26906. */
  26907. getScene(): Scene;
  26908. /**
  26909. * Gets the engine of the node
  26910. * @returns a Engine
  26911. */
  26912. getEngine(): Engine;
  26913. private _behaviors;
  26914. /**
  26915. * Attach a behavior to the node
  26916. * @see http://doc.babylonjs.com/features/behaviour
  26917. * @param behavior defines the behavior to attach
  26918. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26919. * @returns the current Node
  26920. */
  26921. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26922. /**
  26923. * Remove an attached behavior
  26924. * @see http://doc.babylonjs.com/features/behaviour
  26925. * @param behavior defines the behavior to attach
  26926. * @returns the current Node
  26927. */
  26928. removeBehavior(behavior: Behavior<Node>): Node;
  26929. /**
  26930. * Gets the list of attached behaviors
  26931. * @see http://doc.babylonjs.com/features/behaviour
  26932. */
  26933. readonly behaviors: Behavior<Node>[];
  26934. /**
  26935. * Gets an attached behavior by name
  26936. * @param name defines the name of the behavior to look for
  26937. * @see http://doc.babylonjs.com/features/behaviour
  26938. * @returns null if behavior was not found else the requested behavior
  26939. */
  26940. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26941. /**
  26942. * Returns the latest update of the World matrix
  26943. * @returns a Matrix
  26944. */
  26945. getWorldMatrix(): Matrix;
  26946. /** @hidden */
  26947. _getWorldMatrixDeterminant(): number;
  26948. /**
  26949. * Returns directly the latest state of the mesh World matrix.
  26950. * A Matrix is returned.
  26951. */
  26952. readonly worldMatrixFromCache: Matrix;
  26953. /** @hidden */
  26954. _initCache(): void;
  26955. /** @hidden */
  26956. updateCache(force?: boolean): void;
  26957. /** @hidden */
  26958. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26959. /** @hidden */
  26960. _updateCache(ignoreParentClass?: boolean): void;
  26961. /** @hidden */
  26962. _isSynchronized(): boolean;
  26963. /** @hidden */
  26964. _markSyncedWithParent(): void;
  26965. /** @hidden */
  26966. isSynchronizedWithParent(): boolean;
  26967. /** @hidden */
  26968. isSynchronized(): boolean;
  26969. /**
  26970. * Is this node ready to be used/rendered
  26971. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26972. * @return true if the node is ready
  26973. */
  26974. isReady(completeCheck?: boolean): boolean;
  26975. /**
  26976. * Is this node enabled?
  26977. * 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
  26978. * @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
  26979. * @return whether this node (and its parent) is enabled
  26980. */
  26981. isEnabled(checkAncestors?: boolean): boolean;
  26982. /** @hidden */
  26983. protected _syncParentEnabledState(): void;
  26984. /**
  26985. * Set the enabled state of this node
  26986. * @param value defines the new enabled state
  26987. */
  26988. setEnabled(value: boolean): void;
  26989. /**
  26990. * Is this node a descendant of the given node?
  26991. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26992. * @param ancestor defines the parent node to inspect
  26993. * @returns a boolean indicating if this node is a descendant of the given node
  26994. */
  26995. isDescendantOf(ancestor: Node): boolean;
  26996. /** @hidden */
  26997. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26998. /**
  26999. * Will return all nodes that have this node as ascendant
  27000. * @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
  27001. * @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
  27002. * @return all children nodes of all types
  27003. */
  27004. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27005. /**
  27006. * Get all child-meshes of this node
  27007. * @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)
  27008. * @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
  27009. * @returns an array of AbstractMesh
  27010. */
  27011. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27012. /**
  27013. * Get all direct children of this node
  27014. * @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
  27015. * @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)
  27016. * @returns an array of Node
  27017. */
  27018. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27019. /** @hidden */
  27020. _setReady(state: boolean): void;
  27021. /**
  27022. * Get an animation by name
  27023. * @param name defines the name of the animation to look for
  27024. * @returns null if not found else the requested animation
  27025. */
  27026. getAnimationByName(name: string): Nullable<Animation>;
  27027. /**
  27028. * Creates an animation range for this node
  27029. * @param name defines the name of the range
  27030. * @param from defines the starting key
  27031. * @param to defines the end key
  27032. */
  27033. createAnimationRange(name: string, from: number, to: number): void;
  27034. /**
  27035. * Delete a specific animation range
  27036. * @param name defines the name of the range to delete
  27037. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27038. */
  27039. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27040. /**
  27041. * Get an animation range by name
  27042. * @param name defines the name of the animation range to look for
  27043. * @returns null if not found else the requested animation range
  27044. */
  27045. getAnimationRange(name: string): Nullable<AnimationRange>;
  27046. /**
  27047. * Gets the list of all animation ranges defined on this node
  27048. * @returns an array
  27049. */
  27050. getAnimationRanges(): Nullable<AnimationRange>[];
  27051. /**
  27052. * Will start the animation sequence
  27053. * @param name defines the range frames for animation sequence
  27054. * @param loop defines if the animation should loop (false by default)
  27055. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27056. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27057. * @returns the object created for this animation. If range does not exist, it will return null
  27058. */
  27059. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27060. /**
  27061. * Serialize animation ranges into a JSON compatible object
  27062. * @returns serialization object
  27063. */
  27064. serializeAnimationRanges(): any;
  27065. /**
  27066. * Computes the world matrix of the node
  27067. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27068. * @returns the world matrix
  27069. */
  27070. computeWorldMatrix(force?: boolean): Matrix;
  27071. /**
  27072. * Releases resources associated with this node.
  27073. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27074. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27075. */
  27076. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27077. /**
  27078. * Parse animation range data from a serialization object and store them into a given node
  27079. * @param node defines where to store the animation ranges
  27080. * @param parsedNode defines the serialization object to read data from
  27081. * @param scene defines the hosting scene
  27082. */
  27083. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27084. /**
  27085. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27086. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27087. * @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
  27088. * @returns the new bounding vectors
  27089. */
  27090. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27091. min: Vector3;
  27092. max: Vector3;
  27093. };
  27094. }
  27095. }
  27096. declare module BABYLON {
  27097. /**
  27098. * @hidden
  27099. */
  27100. export class _IAnimationState {
  27101. key: number;
  27102. repeatCount: number;
  27103. workValue?: any;
  27104. loopMode?: number;
  27105. offsetValue?: any;
  27106. highLimitValue?: any;
  27107. }
  27108. /**
  27109. * Class used to store any kind of animation
  27110. */
  27111. export class Animation {
  27112. /**Name of the animation */
  27113. name: string;
  27114. /**Property to animate */
  27115. targetProperty: string;
  27116. /**The frames per second of the animation */
  27117. framePerSecond: number;
  27118. /**The data type of the animation */
  27119. dataType: number;
  27120. /**The loop mode of the animation */
  27121. loopMode?: number | undefined;
  27122. /**Specifies if blending should be enabled */
  27123. enableBlending?: boolean | undefined;
  27124. /**
  27125. * Use matrix interpolation instead of using direct key value when animating matrices
  27126. */
  27127. static AllowMatricesInterpolation: boolean;
  27128. /**
  27129. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27130. */
  27131. static AllowMatrixDecomposeForInterpolation: boolean;
  27132. /**
  27133. * Stores the key frames of the animation
  27134. */
  27135. private _keys;
  27136. /**
  27137. * Stores the easing function of the animation
  27138. */
  27139. private _easingFunction;
  27140. /**
  27141. * @hidden Internal use only
  27142. */
  27143. _runtimeAnimations: RuntimeAnimation[];
  27144. /**
  27145. * The set of event that will be linked to this animation
  27146. */
  27147. private _events;
  27148. /**
  27149. * Stores an array of target property paths
  27150. */
  27151. targetPropertyPath: string[];
  27152. /**
  27153. * Stores the blending speed of the animation
  27154. */
  27155. blendingSpeed: number;
  27156. /**
  27157. * Stores the animation ranges for the animation
  27158. */
  27159. private _ranges;
  27160. /**
  27161. * @hidden Internal use
  27162. */
  27163. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27164. /**
  27165. * Sets up an animation
  27166. * @param property The property to animate
  27167. * @param animationType The animation type to apply
  27168. * @param framePerSecond The frames per second of the animation
  27169. * @param easingFunction The easing function used in the animation
  27170. * @returns The created animation
  27171. */
  27172. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27173. /**
  27174. * Create and start an animation on a node
  27175. * @param name defines the name of the global animation that will be run on all nodes
  27176. * @param node defines the root node where the animation will take place
  27177. * @param targetProperty defines property to animate
  27178. * @param framePerSecond defines the number of frame per second yo use
  27179. * @param totalFrame defines the number of frames in total
  27180. * @param from defines the initial value
  27181. * @param to defines the final value
  27182. * @param loopMode defines which loop mode you want to use (off by default)
  27183. * @param easingFunction defines the easing function to use (linear by default)
  27184. * @param onAnimationEnd defines the callback to call when animation end
  27185. * @returns the animatable created for this animation
  27186. */
  27187. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27188. /**
  27189. * Create and start an animation on a node and its descendants
  27190. * @param name defines the name of the global animation that will be run on all nodes
  27191. * @param node defines the root node where the animation will take place
  27192. * @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
  27193. * @param targetProperty defines property to animate
  27194. * @param framePerSecond defines the number of frame per second to use
  27195. * @param totalFrame defines the number of frames in total
  27196. * @param from defines the initial value
  27197. * @param to defines the final value
  27198. * @param loopMode defines which loop mode you want to use (off by default)
  27199. * @param easingFunction defines the easing function to use (linear by default)
  27200. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27201. * @returns the list of animatables created for all nodes
  27202. * @example https://www.babylonjs-playground.com/#MH0VLI
  27203. */
  27204. 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[]>;
  27205. /**
  27206. * Creates a new animation, merges it with the existing animations and starts it
  27207. * @param name Name of the animation
  27208. * @param node Node which contains the scene that begins the animations
  27209. * @param targetProperty Specifies which property to animate
  27210. * @param framePerSecond The frames per second of the animation
  27211. * @param totalFrame The total number of frames
  27212. * @param from The frame at the beginning of the animation
  27213. * @param to The frame at the end of the animation
  27214. * @param loopMode Specifies the loop mode of the animation
  27215. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27216. * @param onAnimationEnd Callback to run once the animation is complete
  27217. * @returns Nullable animation
  27218. */
  27219. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27220. /**
  27221. * Transition property of an host to the target Value
  27222. * @param property The property to transition
  27223. * @param targetValue The target Value of the property
  27224. * @param host The object where the property to animate belongs
  27225. * @param scene Scene used to run the animation
  27226. * @param frameRate Framerate (in frame/s) to use
  27227. * @param transition The transition type we want to use
  27228. * @param duration The duration of the animation, in milliseconds
  27229. * @param onAnimationEnd Callback trigger at the end of the animation
  27230. * @returns Nullable animation
  27231. */
  27232. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27233. /**
  27234. * Return the array of runtime animations currently using this animation
  27235. */
  27236. readonly runtimeAnimations: RuntimeAnimation[];
  27237. /**
  27238. * Specifies if any of the runtime animations are currently running
  27239. */
  27240. readonly hasRunningRuntimeAnimations: boolean;
  27241. /**
  27242. * Initializes the animation
  27243. * @param name Name of the animation
  27244. * @param targetProperty Property to animate
  27245. * @param framePerSecond The frames per second of the animation
  27246. * @param dataType The data type of the animation
  27247. * @param loopMode The loop mode of the animation
  27248. * @param enableBlending Specifies if blending should be enabled
  27249. */
  27250. constructor(
  27251. /**Name of the animation */
  27252. name: string,
  27253. /**Property to animate */
  27254. targetProperty: string,
  27255. /**The frames per second of the animation */
  27256. framePerSecond: number,
  27257. /**The data type of the animation */
  27258. dataType: number,
  27259. /**The loop mode of the animation */
  27260. loopMode?: number | undefined,
  27261. /**Specifies if blending should be enabled */
  27262. enableBlending?: boolean | undefined);
  27263. /**
  27264. * Converts the animation to a string
  27265. * @param fullDetails support for multiple levels of logging within scene loading
  27266. * @returns String form of the animation
  27267. */
  27268. toString(fullDetails?: boolean): string;
  27269. /**
  27270. * Add an event to this animation
  27271. * @param event Event to add
  27272. */
  27273. addEvent(event: AnimationEvent): void;
  27274. /**
  27275. * Remove all events found at the given frame
  27276. * @param frame The frame to remove events from
  27277. */
  27278. removeEvents(frame: number): void;
  27279. /**
  27280. * Retrieves all the events from the animation
  27281. * @returns Events from the animation
  27282. */
  27283. getEvents(): AnimationEvent[];
  27284. /**
  27285. * Creates an animation range
  27286. * @param name Name of the animation range
  27287. * @param from Starting frame of the animation range
  27288. * @param to Ending frame of the animation
  27289. */
  27290. createRange(name: string, from: number, to: number): void;
  27291. /**
  27292. * Deletes an animation range by name
  27293. * @param name Name of the animation range to delete
  27294. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27295. */
  27296. deleteRange(name: string, deleteFrames?: boolean): void;
  27297. /**
  27298. * Gets the animation range by name, or null if not defined
  27299. * @param name Name of the animation range
  27300. * @returns Nullable animation range
  27301. */
  27302. getRange(name: string): Nullable<AnimationRange>;
  27303. /**
  27304. * Gets the key frames from the animation
  27305. * @returns The key frames of the animation
  27306. */
  27307. getKeys(): Array<IAnimationKey>;
  27308. /**
  27309. * Gets the highest frame rate of the animation
  27310. * @returns Highest frame rate of the animation
  27311. */
  27312. getHighestFrame(): number;
  27313. /**
  27314. * Gets the easing function of the animation
  27315. * @returns Easing function of the animation
  27316. */
  27317. getEasingFunction(): IEasingFunction;
  27318. /**
  27319. * Sets the easing function of the animation
  27320. * @param easingFunction A custom mathematical formula for animation
  27321. */
  27322. setEasingFunction(easingFunction: EasingFunction): void;
  27323. /**
  27324. * Interpolates a scalar linearly
  27325. * @param startValue Start value of the animation curve
  27326. * @param endValue End value of the animation curve
  27327. * @param gradient Scalar amount to interpolate
  27328. * @returns Interpolated scalar value
  27329. */
  27330. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27331. /**
  27332. * Interpolates a scalar cubically
  27333. * @param startValue Start value of the animation curve
  27334. * @param outTangent End tangent of the animation
  27335. * @param endValue End value of the animation curve
  27336. * @param inTangent Start tangent of the animation curve
  27337. * @param gradient Scalar amount to interpolate
  27338. * @returns Interpolated scalar value
  27339. */
  27340. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27341. /**
  27342. * Interpolates a quaternion using a spherical linear interpolation
  27343. * @param startValue Start value of the animation curve
  27344. * @param endValue End value of the animation curve
  27345. * @param gradient Scalar amount to interpolate
  27346. * @returns Interpolated quaternion value
  27347. */
  27348. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27349. /**
  27350. * Interpolates a quaternion cubically
  27351. * @param startValue Start value of the animation curve
  27352. * @param outTangent End tangent of the animation curve
  27353. * @param endValue End value of the animation curve
  27354. * @param inTangent Start tangent of the animation curve
  27355. * @param gradient Scalar amount to interpolate
  27356. * @returns Interpolated quaternion value
  27357. */
  27358. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27359. /**
  27360. * Interpolates a Vector3 linearl
  27361. * @param startValue Start value of the animation curve
  27362. * @param endValue End value of the animation curve
  27363. * @param gradient Scalar amount to interpolate
  27364. * @returns Interpolated scalar value
  27365. */
  27366. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27367. /**
  27368. * Interpolates a Vector3 cubically
  27369. * @param startValue Start value of the animation curve
  27370. * @param outTangent End tangent of the animation
  27371. * @param endValue End value of the animation curve
  27372. * @param inTangent Start tangent of the animation curve
  27373. * @param gradient Scalar amount to interpolate
  27374. * @returns InterpolatedVector3 value
  27375. */
  27376. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27377. /**
  27378. * Interpolates a Vector2 linearly
  27379. * @param startValue Start value of the animation curve
  27380. * @param endValue End value of the animation curve
  27381. * @param gradient Scalar amount to interpolate
  27382. * @returns Interpolated Vector2 value
  27383. */
  27384. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27385. /**
  27386. * Interpolates a Vector2 cubically
  27387. * @param startValue Start value of the animation curve
  27388. * @param outTangent End tangent of the animation
  27389. * @param endValue End value of the animation curve
  27390. * @param inTangent Start tangent of the animation curve
  27391. * @param gradient Scalar amount to interpolate
  27392. * @returns Interpolated Vector2 value
  27393. */
  27394. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27395. /**
  27396. * Interpolates a size linearly
  27397. * @param startValue Start value of the animation curve
  27398. * @param endValue End value of the animation curve
  27399. * @param gradient Scalar amount to interpolate
  27400. * @returns Interpolated Size value
  27401. */
  27402. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27403. /**
  27404. * Interpolates a Color3 linearly
  27405. * @param startValue Start value of the animation curve
  27406. * @param endValue End value of the animation curve
  27407. * @param gradient Scalar amount to interpolate
  27408. * @returns Interpolated Color3 value
  27409. */
  27410. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27411. /**
  27412. * @hidden Internal use only
  27413. */
  27414. _getKeyValue(value: any): any;
  27415. /**
  27416. * @hidden Internal use only
  27417. */
  27418. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27419. /**
  27420. * Defines the function to use to interpolate matrices
  27421. * @param startValue defines the start matrix
  27422. * @param endValue defines the end matrix
  27423. * @param gradient defines the gradient between both matrices
  27424. * @param result defines an optional target matrix where to store the interpolation
  27425. * @returns the interpolated matrix
  27426. */
  27427. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27428. /**
  27429. * Makes a copy of the animation
  27430. * @returns Cloned animation
  27431. */
  27432. clone(): Animation;
  27433. /**
  27434. * Sets the key frames of the animation
  27435. * @param values The animation key frames to set
  27436. */
  27437. setKeys(values: Array<IAnimationKey>): void;
  27438. /**
  27439. * Serializes the animation to an object
  27440. * @returns Serialized object
  27441. */
  27442. serialize(): any;
  27443. /**
  27444. * Float animation type
  27445. */
  27446. private static _ANIMATIONTYPE_FLOAT;
  27447. /**
  27448. * Vector3 animation type
  27449. */
  27450. private static _ANIMATIONTYPE_VECTOR3;
  27451. /**
  27452. * Quaternion animation type
  27453. */
  27454. private static _ANIMATIONTYPE_QUATERNION;
  27455. /**
  27456. * Matrix animation type
  27457. */
  27458. private static _ANIMATIONTYPE_MATRIX;
  27459. /**
  27460. * Color3 animation type
  27461. */
  27462. private static _ANIMATIONTYPE_COLOR3;
  27463. /**
  27464. * Vector2 animation type
  27465. */
  27466. private static _ANIMATIONTYPE_VECTOR2;
  27467. /**
  27468. * Size animation type
  27469. */
  27470. private static _ANIMATIONTYPE_SIZE;
  27471. /**
  27472. * Relative Loop Mode
  27473. */
  27474. private static _ANIMATIONLOOPMODE_RELATIVE;
  27475. /**
  27476. * Cycle Loop Mode
  27477. */
  27478. private static _ANIMATIONLOOPMODE_CYCLE;
  27479. /**
  27480. * Constant Loop Mode
  27481. */
  27482. private static _ANIMATIONLOOPMODE_CONSTANT;
  27483. /**
  27484. * Get the float animation type
  27485. */
  27486. static readonly ANIMATIONTYPE_FLOAT: number;
  27487. /**
  27488. * Get the Vector3 animation type
  27489. */
  27490. static readonly ANIMATIONTYPE_VECTOR3: number;
  27491. /**
  27492. * Get the Vector2 animation type
  27493. */
  27494. static readonly ANIMATIONTYPE_VECTOR2: number;
  27495. /**
  27496. * Get the Size animation type
  27497. */
  27498. static readonly ANIMATIONTYPE_SIZE: number;
  27499. /**
  27500. * Get the Quaternion animation type
  27501. */
  27502. static readonly ANIMATIONTYPE_QUATERNION: number;
  27503. /**
  27504. * Get the Matrix animation type
  27505. */
  27506. static readonly ANIMATIONTYPE_MATRIX: number;
  27507. /**
  27508. * Get the Color3 animation type
  27509. */
  27510. static readonly ANIMATIONTYPE_COLOR3: number;
  27511. /**
  27512. * Get the Relative Loop Mode
  27513. */
  27514. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27515. /**
  27516. * Get the Cycle Loop Mode
  27517. */
  27518. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27519. /**
  27520. * Get the Constant Loop Mode
  27521. */
  27522. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27523. /** @hidden */
  27524. static _UniversalLerp(left: any, right: any, amount: number): any;
  27525. /**
  27526. * Parses an animation object and creates an animation
  27527. * @param parsedAnimation Parsed animation object
  27528. * @returns Animation object
  27529. */
  27530. static Parse(parsedAnimation: any): Animation;
  27531. /**
  27532. * Appends the serialized animations from the source animations
  27533. * @param source Source containing the animations
  27534. * @param destination Target to store the animations
  27535. */
  27536. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27537. }
  27538. }
  27539. declare module BABYLON {
  27540. /**
  27541. * Interface containing an array of animations
  27542. */
  27543. export interface IAnimatable {
  27544. /**
  27545. * Array of animations
  27546. */
  27547. animations: Nullable<Array<Animation>>;
  27548. }
  27549. }
  27550. declare module BABYLON {
  27551. /**
  27552. * This represents all the required information to add a fresnel effect on a material:
  27553. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27554. */
  27555. export class FresnelParameters {
  27556. private _isEnabled;
  27557. /**
  27558. * Define if the fresnel effect is enable or not.
  27559. */
  27560. isEnabled: boolean;
  27561. /**
  27562. * Define the color used on edges (grazing angle)
  27563. */
  27564. leftColor: Color3;
  27565. /**
  27566. * Define the color used on center
  27567. */
  27568. rightColor: Color3;
  27569. /**
  27570. * Define bias applied to computed fresnel term
  27571. */
  27572. bias: number;
  27573. /**
  27574. * Defined the power exponent applied to fresnel term
  27575. */
  27576. power: number;
  27577. /**
  27578. * Clones the current fresnel and its valuues
  27579. * @returns a clone fresnel configuration
  27580. */
  27581. clone(): FresnelParameters;
  27582. /**
  27583. * Serializes the current fresnel parameters to a JSON representation.
  27584. * @return the JSON serialization
  27585. */
  27586. serialize(): any;
  27587. /**
  27588. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27589. * @param parsedFresnelParameters Define the JSON representation
  27590. * @returns the parsed parameters
  27591. */
  27592. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27593. }
  27594. }
  27595. declare module BABYLON {
  27596. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27597. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27598. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27599. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27600. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27601. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27602. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27603. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27604. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27605. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27606. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27607. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27608. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27609. /**
  27610. * Decorator used to define property that can be serialized as reference to a camera
  27611. * @param sourceName defines the name of the property to decorate
  27612. */
  27613. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27614. /**
  27615. * Class used to help serialization objects
  27616. */
  27617. export class SerializationHelper {
  27618. /** @hidden */
  27619. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27620. /** @hidden */
  27621. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27622. /** @hidden */
  27623. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27624. /** @hidden */
  27625. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27626. /**
  27627. * Appends the serialized animations from the source animations
  27628. * @param source Source containing the animations
  27629. * @param destination Target to store the animations
  27630. */
  27631. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27632. /**
  27633. * Static function used to serialized a specific entity
  27634. * @param entity defines the entity to serialize
  27635. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27636. * @returns a JSON compatible object representing the serialization of the entity
  27637. */
  27638. static Serialize<T>(entity: T, serializationObject?: any): any;
  27639. /**
  27640. * Creates a new entity from a serialization data object
  27641. * @param creationFunction defines a function used to instanciated the new entity
  27642. * @param source defines the source serialization data
  27643. * @param scene defines the hosting scene
  27644. * @param rootUrl defines the root url for resources
  27645. * @returns a new entity
  27646. */
  27647. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27648. /**
  27649. * Clones an object
  27650. * @param creationFunction defines the function used to instanciate the new object
  27651. * @param source defines the source object
  27652. * @returns the cloned object
  27653. */
  27654. static Clone<T>(creationFunction: () => T, source: T): T;
  27655. /**
  27656. * Instanciates a new object based on a source one (some data will be shared between both object)
  27657. * @param creationFunction defines the function used to instanciate the new object
  27658. * @param source defines the source object
  27659. * @returns the new object
  27660. */
  27661. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27662. }
  27663. }
  27664. declare module BABYLON {
  27665. /**
  27666. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27667. */
  27668. export interface CubeMapInfo {
  27669. /**
  27670. * The pixel array for the front face.
  27671. * This is stored in format, left to right, up to down format.
  27672. */
  27673. front: Nullable<ArrayBufferView>;
  27674. /**
  27675. * The pixel array for the back face.
  27676. * This is stored in format, left to right, up to down format.
  27677. */
  27678. back: Nullable<ArrayBufferView>;
  27679. /**
  27680. * The pixel array for the left face.
  27681. * This is stored in format, left to right, up to down format.
  27682. */
  27683. left: Nullable<ArrayBufferView>;
  27684. /**
  27685. * The pixel array for the right face.
  27686. * This is stored in format, left to right, up to down format.
  27687. */
  27688. right: Nullable<ArrayBufferView>;
  27689. /**
  27690. * The pixel array for the up face.
  27691. * This is stored in format, left to right, up to down format.
  27692. */
  27693. up: Nullable<ArrayBufferView>;
  27694. /**
  27695. * The pixel array for the down face.
  27696. * This is stored in format, left to right, up to down format.
  27697. */
  27698. down: Nullable<ArrayBufferView>;
  27699. /**
  27700. * The size of the cubemap stored.
  27701. *
  27702. * Each faces will be size * size pixels.
  27703. */
  27704. size: number;
  27705. /**
  27706. * The format of the texture.
  27707. *
  27708. * RGBA, RGB.
  27709. */
  27710. format: number;
  27711. /**
  27712. * The type of the texture data.
  27713. *
  27714. * UNSIGNED_INT, FLOAT.
  27715. */
  27716. type: number;
  27717. /**
  27718. * Specifies whether the texture is in gamma space.
  27719. */
  27720. gammaSpace: boolean;
  27721. }
  27722. /**
  27723. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27724. */
  27725. export class PanoramaToCubeMapTools {
  27726. private static FACE_FRONT;
  27727. private static FACE_BACK;
  27728. private static FACE_RIGHT;
  27729. private static FACE_LEFT;
  27730. private static FACE_DOWN;
  27731. private static FACE_UP;
  27732. /**
  27733. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27734. *
  27735. * @param float32Array The source data.
  27736. * @param inputWidth The width of the input panorama.
  27737. * @param inputHeight The height of the input panorama.
  27738. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27739. * @return The cubemap data
  27740. */
  27741. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27742. private static CreateCubemapTexture;
  27743. private static CalcProjectionSpherical;
  27744. }
  27745. }
  27746. declare module BABYLON {
  27747. /**
  27748. * Helper class dealing with the extraction of spherical polynomial dataArray
  27749. * from a cube map.
  27750. */
  27751. export class CubeMapToSphericalPolynomialTools {
  27752. private static FileFaces;
  27753. /**
  27754. * Converts a texture to the according Spherical Polynomial data.
  27755. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27756. *
  27757. * @param texture The texture to extract the information from.
  27758. * @return The Spherical Polynomial data.
  27759. */
  27760. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27761. /**
  27762. * Converts a cubemap to the according Spherical Polynomial data.
  27763. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27764. *
  27765. * @param cubeInfo The Cube map to extract the information from.
  27766. * @return The Spherical Polynomial data.
  27767. */
  27768. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27769. }
  27770. }
  27771. declare module BABYLON {
  27772. /**
  27773. * Class used to manipulate GUIDs
  27774. */
  27775. export class GUID {
  27776. /**
  27777. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27778. * Be aware Math.random() could cause collisions, but:
  27779. * "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"
  27780. * @returns a pseudo random id
  27781. */
  27782. static RandomId(): string;
  27783. }
  27784. }
  27785. declare module BABYLON {
  27786. /**
  27787. * Base class of all the textures in babylon.
  27788. * It groups all the common properties the materials, post process, lights... might need
  27789. * in order to make a correct use of the texture.
  27790. */
  27791. export class BaseTexture implements IAnimatable {
  27792. /**
  27793. * Default anisotropic filtering level for the application.
  27794. * It is set to 4 as a good tradeoff between perf and quality.
  27795. */
  27796. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27797. /**
  27798. * Gets or sets the unique id of the texture
  27799. */
  27800. uniqueId: number;
  27801. /**
  27802. * Define the name of the texture.
  27803. */
  27804. name: string;
  27805. /**
  27806. * Gets or sets an object used to store user defined information.
  27807. */
  27808. metadata: any;
  27809. /**
  27810. * For internal use only. Please do not use.
  27811. */
  27812. reservedDataStore: any;
  27813. private _hasAlpha;
  27814. /**
  27815. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27816. */
  27817. hasAlpha: boolean;
  27818. /**
  27819. * Defines if the alpha value should be determined via the rgb values.
  27820. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27821. */
  27822. getAlphaFromRGB: boolean;
  27823. /**
  27824. * Intensity or strength of the texture.
  27825. * It is commonly used by materials to fine tune the intensity of the texture
  27826. */
  27827. level: number;
  27828. /**
  27829. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27830. * This is part of the texture as textures usually maps to one uv set.
  27831. */
  27832. coordinatesIndex: number;
  27833. private _coordinatesMode;
  27834. /**
  27835. * How a texture is mapped.
  27836. *
  27837. * | Value | Type | Description |
  27838. * | ----- | ----------------------------------- | ----------- |
  27839. * | 0 | EXPLICIT_MODE | |
  27840. * | 1 | SPHERICAL_MODE | |
  27841. * | 2 | PLANAR_MODE | |
  27842. * | 3 | CUBIC_MODE | |
  27843. * | 4 | PROJECTION_MODE | |
  27844. * | 5 | SKYBOX_MODE | |
  27845. * | 6 | INVCUBIC_MODE | |
  27846. * | 7 | EQUIRECTANGULAR_MODE | |
  27847. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27848. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27849. */
  27850. coordinatesMode: number;
  27851. /**
  27852. * | Value | Type | Description |
  27853. * | ----- | ------------------ | ----------- |
  27854. * | 0 | CLAMP_ADDRESSMODE | |
  27855. * | 1 | WRAP_ADDRESSMODE | |
  27856. * | 2 | MIRROR_ADDRESSMODE | |
  27857. */
  27858. wrapU: number;
  27859. /**
  27860. * | Value | Type | Description |
  27861. * | ----- | ------------------ | ----------- |
  27862. * | 0 | CLAMP_ADDRESSMODE | |
  27863. * | 1 | WRAP_ADDRESSMODE | |
  27864. * | 2 | MIRROR_ADDRESSMODE | |
  27865. */
  27866. wrapV: number;
  27867. /**
  27868. * | Value | Type | Description |
  27869. * | ----- | ------------------ | ----------- |
  27870. * | 0 | CLAMP_ADDRESSMODE | |
  27871. * | 1 | WRAP_ADDRESSMODE | |
  27872. * | 2 | MIRROR_ADDRESSMODE | |
  27873. */
  27874. wrapR: number;
  27875. /**
  27876. * With compliant hardware and browser (supporting anisotropic filtering)
  27877. * this defines the level of anisotropic filtering in the texture.
  27878. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27879. */
  27880. anisotropicFilteringLevel: number;
  27881. /**
  27882. * Define if the texture is a cube texture or if false a 2d texture.
  27883. */
  27884. isCube: boolean;
  27885. /**
  27886. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27887. */
  27888. is3D: boolean;
  27889. /**
  27890. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27891. * HDR texture are usually stored in linear space.
  27892. * This only impacts the PBR and Background materials
  27893. */
  27894. gammaSpace: boolean;
  27895. /**
  27896. * Gets or sets whether or not the texture contains RGBD data.
  27897. */
  27898. isRGBD: boolean;
  27899. /**
  27900. * Is Z inverted in the texture (useful in a cube texture).
  27901. */
  27902. invertZ: boolean;
  27903. /**
  27904. * Are mip maps generated for this texture or not.
  27905. */
  27906. readonly noMipmap: boolean;
  27907. /**
  27908. * @hidden
  27909. */
  27910. lodLevelInAlpha: boolean;
  27911. /**
  27912. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27913. */
  27914. lodGenerationOffset: number;
  27915. /**
  27916. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27917. */
  27918. lodGenerationScale: number;
  27919. /**
  27920. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27921. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27922. * average roughness values.
  27923. */
  27924. linearSpecularLOD: boolean;
  27925. /**
  27926. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27927. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27928. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27929. */
  27930. irradianceTexture: Nullable<BaseTexture>;
  27931. /**
  27932. * Define if the texture is a render target.
  27933. */
  27934. isRenderTarget: boolean;
  27935. /**
  27936. * Define the unique id of the texture in the scene.
  27937. */
  27938. readonly uid: string;
  27939. /**
  27940. * Return a string representation of the texture.
  27941. * @returns the texture as a string
  27942. */
  27943. toString(): string;
  27944. /**
  27945. * Get the class name of the texture.
  27946. * @returns "BaseTexture"
  27947. */
  27948. getClassName(): string;
  27949. /**
  27950. * Define the list of animation attached to the texture.
  27951. */
  27952. animations: Animation[];
  27953. /**
  27954. * An event triggered when the texture is disposed.
  27955. */
  27956. onDisposeObservable: Observable<BaseTexture>;
  27957. private _onDisposeObserver;
  27958. /**
  27959. * Callback triggered when the texture has been disposed.
  27960. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27961. */
  27962. onDispose: () => void;
  27963. /**
  27964. * Define the current state of the loading sequence when in delayed load mode.
  27965. */
  27966. delayLoadState: number;
  27967. private _scene;
  27968. /** @hidden */
  27969. _texture: Nullable<InternalTexture>;
  27970. private _uid;
  27971. /**
  27972. * Define if the texture is preventinga material to render or not.
  27973. * If not and the texture is not ready, the engine will use a default black texture instead.
  27974. */
  27975. readonly isBlocking: boolean;
  27976. /**
  27977. * Instantiates a new BaseTexture.
  27978. * Base class of all the textures in babylon.
  27979. * It groups all the common properties the materials, post process, lights... might need
  27980. * in order to make a correct use of the texture.
  27981. * @param scene Define the scene the texture blongs to
  27982. */
  27983. constructor(scene: Nullable<Scene>);
  27984. /**
  27985. * Get the scene the texture belongs to.
  27986. * @returns the scene or null if undefined
  27987. */
  27988. getScene(): Nullable<Scene>;
  27989. /**
  27990. * Get the texture transform matrix used to offset tile the texture for istance.
  27991. * @returns the transformation matrix
  27992. */
  27993. getTextureMatrix(): Matrix;
  27994. /**
  27995. * Get the texture reflection matrix used to rotate/transform the reflection.
  27996. * @returns the reflection matrix
  27997. */
  27998. getReflectionTextureMatrix(): Matrix;
  27999. /**
  28000. * Get the underlying lower level texture from Babylon.
  28001. * @returns the insternal texture
  28002. */
  28003. getInternalTexture(): Nullable<InternalTexture>;
  28004. /**
  28005. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28006. * @returns true if ready or not blocking
  28007. */
  28008. isReadyOrNotBlocking(): boolean;
  28009. /**
  28010. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28011. * @returns true if fully ready
  28012. */
  28013. isReady(): boolean;
  28014. private _cachedSize;
  28015. /**
  28016. * Get the size of the texture.
  28017. * @returns the texture size.
  28018. */
  28019. getSize(): ISize;
  28020. /**
  28021. * Get the base size of the texture.
  28022. * It can be different from the size if the texture has been resized for POT for instance
  28023. * @returns the base size
  28024. */
  28025. getBaseSize(): ISize;
  28026. /**
  28027. * Update the sampling mode of the texture.
  28028. * Default is Trilinear mode.
  28029. *
  28030. * | Value | Type | Description |
  28031. * | ----- | ------------------ | ----------- |
  28032. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28033. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28034. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28035. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28036. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28037. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28038. * | 7 | NEAREST_LINEAR | |
  28039. * | 8 | NEAREST_NEAREST | |
  28040. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28041. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28042. * | 11 | LINEAR_LINEAR | |
  28043. * | 12 | LINEAR_NEAREST | |
  28044. *
  28045. * > _mag_: magnification filter (close to the viewer)
  28046. * > _min_: minification filter (far from the viewer)
  28047. * > _mip_: filter used between mip map levels
  28048. *@param samplingMode Define the new sampling mode of the texture
  28049. */
  28050. updateSamplingMode(samplingMode: number): void;
  28051. /**
  28052. * Scales the texture if is `canRescale()`
  28053. * @param ratio the resize factor we want to use to rescale
  28054. */
  28055. scale(ratio: number): void;
  28056. /**
  28057. * Get if the texture can rescale.
  28058. */
  28059. readonly canRescale: boolean;
  28060. /** @hidden */
  28061. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28062. /** @hidden */
  28063. _rebuild(): void;
  28064. /**
  28065. * Triggers the load sequence in delayed load mode.
  28066. */
  28067. delayLoad(): void;
  28068. /**
  28069. * Clones the texture.
  28070. * @returns the cloned texture
  28071. */
  28072. clone(): Nullable<BaseTexture>;
  28073. /**
  28074. * Get the texture underlying type (INT, FLOAT...)
  28075. */
  28076. readonly textureType: number;
  28077. /**
  28078. * Get the texture underlying format (RGB, RGBA...)
  28079. */
  28080. readonly textureFormat: number;
  28081. /**
  28082. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28083. * This will returns an RGBA array buffer containing either in values (0-255) or
  28084. * float values (0-1) depending of the underlying buffer type.
  28085. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28086. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28087. * @param buffer defines a user defined buffer to fill with data (can be null)
  28088. * @returns The Array buffer containing the pixels data.
  28089. */
  28090. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28091. /**
  28092. * Release and destroy the underlying lower level texture aka internalTexture.
  28093. */
  28094. releaseInternalTexture(): void;
  28095. /**
  28096. * Get the polynomial representation of the texture data.
  28097. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28098. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28099. */
  28100. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28101. /** @hidden */
  28102. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28103. /** @hidden */
  28104. readonly _lodTextureMid: Nullable<BaseTexture>;
  28105. /** @hidden */
  28106. readonly _lodTextureLow: Nullable<BaseTexture>;
  28107. /**
  28108. * Dispose the texture and release its associated resources.
  28109. */
  28110. dispose(): void;
  28111. /**
  28112. * Serialize the texture into a JSON representation that can be parsed later on.
  28113. * @returns the JSON representation of the texture
  28114. */
  28115. serialize(): any;
  28116. /**
  28117. * Helper function to be called back once a list of texture contains only ready textures.
  28118. * @param textures Define the list of textures to wait for
  28119. * @param callback Define the callback triggered once the entire list will be ready
  28120. */
  28121. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28122. }
  28123. }
  28124. declare module BABYLON {
  28125. /**
  28126. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28127. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28128. */
  28129. export class EffectFallbacks {
  28130. private _defines;
  28131. private _currentRank;
  28132. private _maxRank;
  28133. private _mesh;
  28134. /**
  28135. * Removes the fallback from the bound mesh.
  28136. */
  28137. unBindMesh(): void;
  28138. /**
  28139. * Adds a fallback on the specified property.
  28140. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28141. * @param define The name of the define in the shader
  28142. */
  28143. addFallback(rank: number, define: string): void;
  28144. /**
  28145. * Sets the mesh to use CPU skinning when needing to fallback.
  28146. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28147. * @param mesh The mesh to use the fallbacks.
  28148. */
  28149. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28150. /**
  28151. * Checks to see if more fallbacks are still availible.
  28152. */
  28153. readonly hasMoreFallbacks: boolean;
  28154. /**
  28155. * Removes the defines that should be removed when falling back.
  28156. * @param currentDefines defines the current define statements for the shader.
  28157. * @param effect defines the current effect we try to compile
  28158. * @returns The resulting defines with defines of the current rank removed.
  28159. */
  28160. reduce(currentDefines: string, effect: Effect): string;
  28161. }
  28162. /**
  28163. * Options to be used when creating an effect.
  28164. */
  28165. export class EffectCreationOptions {
  28166. /**
  28167. * Atrributes that will be used in the shader.
  28168. */
  28169. attributes: string[];
  28170. /**
  28171. * Uniform varible names that will be set in the shader.
  28172. */
  28173. uniformsNames: string[];
  28174. /**
  28175. * Uniform buffer varible names that will be set in the shader.
  28176. */
  28177. uniformBuffersNames: string[];
  28178. /**
  28179. * Sampler texture variable names that will be set in the shader.
  28180. */
  28181. samplers: string[];
  28182. /**
  28183. * Define statements that will be set in the shader.
  28184. */
  28185. defines: any;
  28186. /**
  28187. * Possible fallbacks for this effect to improve performance when needed.
  28188. */
  28189. fallbacks: Nullable<EffectFallbacks>;
  28190. /**
  28191. * Callback that will be called when the shader is compiled.
  28192. */
  28193. onCompiled: Nullable<(effect: Effect) => void>;
  28194. /**
  28195. * Callback that will be called if an error occurs during shader compilation.
  28196. */
  28197. onError: Nullable<(effect: Effect, errors: string) => void>;
  28198. /**
  28199. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28200. */
  28201. indexParameters: any;
  28202. /**
  28203. * Max number of lights that can be used in the shader.
  28204. */
  28205. maxSimultaneousLights: number;
  28206. /**
  28207. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28208. */
  28209. transformFeedbackVaryings: Nullable<string[]>;
  28210. }
  28211. /**
  28212. * Effect containing vertex and fragment shader that can be executed on an object.
  28213. */
  28214. export class Effect implements IDisposable {
  28215. /**
  28216. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28217. */
  28218. static ShadersRepository: string;
  28219. /**
  28220. * Name of the effect.
  28221. */
  28222. name: any;
  28223. /**
  28224. * String container all the define statements that should be set on the shader.
  28225. */
  28226. defines: string;
  28227. /**
  28228. * Callback that will be called when the shader is compiled.
  28229. */
  28230. onCompiled: Nullable<(effect: Effect) => void>;
  28231. /**
  28232. * Callback that will be called if an error occurs during shader compilation.
  28233. */
  28234. onError: Nullable<(effect: Effect, errors: string) => void>;
  28235. /**
  28236. * Callback that will be called when effect is bound.
  28237. */
  28238. onBind: Nullable<(effect: Effect) => void>;
  28239. /**
  28240. * Unique ID of the effect.
  28241. */
  28242. uniqueId: number;
  28243. /**
  28244. * Observable that will be called when the shader is compiled.
  28245. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28246. */
  28247. onCompileObservable: Observable<Effect>;
  28248. /**
  28249. * Observable that will be called if an error occurs during shader compilation.
  28250. */
  28251. onErrorObservable: Observable<Effect>;
  28252. /** @hidden */
  28253. _onBindObservable: Nullable<Observable<Effect>>;
  28254. /**
  28255. * Observable that will be called when effect is bound.
  28256. */
  28257. readonly onBindObservable: Observable<Effect>;
  28258. /** @hidden */
  28259. _bonesComputationForcedToCPU: boolean;
  28260. private static _uniqueIdSeed;
  28261. private _engine;
  28262. private _uniformBuffersNames;
  28263. private _uniformsNames;
  28264. private _samplerList;
  28265. private _samplers;
  28266. private _isReady;
  28267. private _compilationError;
  28268. private _attributesNames;
  28269. private _attributes;
  28270. private _uniforms;
  28271. /**
  28272. * Key for the effect.
  28273. * @hidden
  28274. */
  28275. _key: string;
  28276. private _indexParameters;
  28277. private _fallbacks;
  28278. private _vertexSourceCode;
  28279. private _fragmentSourceCode;
  28280. private _vertexSourceCodeOverride;
  28281. private _fragmentSourceCodeOverride;
  28282. private _transformFeedbackVaryings;
  28283. /**
  28284. * Compiled shader to webGL program.
  28285. * @hidden
  28286. */
  28287. _pipelineContext: Nullable<IPipelineContext>;
  28288. private _valueCache;
  28289. private static _baseCache;
  28290. /**
  28291. * Instantiates an effect.
  28292. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28293. * @param baseName Name of the effect.
  28294. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28295. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28296. * @param samplers List of sampler variables that will be passed to the shader.
  28297. * @param engine Engine to be used to render the effect
  28298. * @param defines Define statements to be added to the shader.
  28299. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28300. * @param onCompiled Callback that will be called when the shader is compiled.
  28301. * @param onError Callback that will be called if an error occurs during shader compilation.
  28302. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28303. */
  28304. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28305. private _useFinalCode;
  28306. /**
  28307. * Unique key for this effect
  28308. */
  28309. readonly key: string;
  28310. /**
  28311. * If the effect has been compiled and prepared.
  28312. * @returns if the effect is compiled and prepared.
  28313. */
  28314. isReady(): boolean;
  28315. private _isReadyInternal;
  28316. /**
  28317. * The engine the effect was initialized with.
  28318. * @returns the engine.
  28319. */
  28320. getEngine(): Engine;
  28321. /**
  28322. * The pipeline context for this effect
  28323. * @returns the associated pipeline context
  28324. */
  28325. getPipelineContext(): Nullable<IPipelineContext>;
  28326. /**
  28327. * The set of names of attribute variables for the shader.
  28328. * @returns An array of attribute names.
  28329. */
  28330. getAttributesNames(): string[];
  28331. /**
  28332. * Returns the attribute at the given index.
  28333. * @param index The index of the attribute.
  28334. * @returns The location of the attribute.
  28335. */
  28336. getAttributeLocation(index: number): number;
  28337. /**
  28338. * Returns the attribute based on the name of the variable.
  28339. * @param name of the attribute to look up.
  28340. * @returns the attribute location.
  28341. */
  28342. getAttributeLocationByName(name: string): number;
  28343. /**
  28344. * The number of attributes.
  28345. * @returns the numnber of attributes.
  28346. */
  28347. getAttributesCount(): number;
  28348. /**
  28349. * Gets the index of a uniform variable.
  28350. * @param uniformName of the uniform to look up.
  28351. * @returns the index.
  28352. */
  28353. getUniformIndex(uniformName: string): number;
  28354. /**
  28355. * Returns the attribute based on the name of the variable.
  28356. * @param uniformName of the uniform to look up.
  28357. * @returns the location of the uniform.
  28358. */
  28359. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28360. /**
  28361. * Returns an array of sampler variable names
  28362. * @returns The array of sampler variable neames.
  28363. */
  28364. getSamplers(): string[];
  28365. /**
  28366. * The error from the last compilation.
  28367. * @returns the error string.
  28368. */
  28369. getCompilationError(): string;
  28370. /**
  28371. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28372. * @param func The callback to be used.
  28373. */
  28374. executeWhenCompiled(func: (effect: Effect) => void): void;
  28375. private _checkIsReady;
  28376. /** @hidden */
  28377. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28378. /** @hidden */
  28379. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28380. /** @hidden */
  28381. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28382. /**
  28383. * Recompiles the webGL program
  28384. * @param vertexSourceCode The source code for the vertex shader.
  28385. * @param fragmentSourceCode The source code for the fragment shader.
  28386. * @param onCompiled Callback called when completed.
  28387. * @param onError Callback called on error.
  28388. * @hidden
  28389. */
  28390. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28391. /**
  28392. * Prepares the effect
  28393. * @hidden
  28394. */
  28395. _prepareEffect(): void;
  28396. private _processCompilationErrors;
  28397. /**
  28398. * Checks if the effect is supported. (Must be called after compilation)
  28399. */
  28400. readonly isSupported: boolean;
  28401. /**
  28402. * Binds a texture to the engine to be used as output of the shader.
  28403. * @param channel Name of the output variable.
  28404. * @param texture Texture to bind.
  28405. * @hidden
  28406. */
  28407. _bindTexture(channel: string, texture: InternalTexture): void;
  28408. /**
  28409. * Sets a texture on the engine to be used in the shader.
  28410. * @param channel Name of the sampler variable.
  28411. * @param texture Texture to set.
  28412. */
  28413. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28414. /**
  28415. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28416. * @param channel Name of the sampler variable.
  28417. * @param texture Texture to set.
  28418. */
  28419. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28420. /**
  28421. * Sets an array of textures on the engine to be used in the shader.
  28422. * @param channel Name of the variable.
  28423. * @param textures Textures to set.
  28424. */
  28425. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28426. /**
  28427. * 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)
  28428. * @param channel Name of the sampler variable.
  28429. * @param postProcess Post process to get the input texture from.
  28430. */
  28431. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28432. /**
  28433. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28434. * 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)
  28435. * @param channel Name of the sampler variable.
  28436. * @param postProcess Post process to get the output texture from.
  28437. */
  28438. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28439. /** @hidden */
  28440. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28441. /** @hidden */
  28442. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28443. /** @hidden */
  28444. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28445. /** @hidden */
  28446. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28447. /**
  28448. * Binds a buffer to a uniform.
  28449. * @param buffer Buffer to bind.
  28450. * @param name Name of the uniform variable to bind to.
  28451. */
  28452. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28453. /**
  28454. * Binds block to a uniform.
  28455. * @param blockName Name of the block to bind.
  28456. * @param index Index to bind.
  28457. */
  28458. bindUniformBlock(blockName: string, index: number): void;
  28459. /**
  28460. * Sets an interger value on a uniform variable.
  28461. * @param uniformName Name of the variable.
  28462. * @param value Value to be set.
  28463. * @returns this effect.
  28464. */
  28465. setInt(uniformName: string, value: number): Effect;
  28466. /**
  28467. * Sets an int array on a uniform variable.
  28468. * @param uniformName Name of the variable.
  28469. * @param array array to be set.
  28470. * @returns this effect.
  28471. */
  28472. setIntArray(uniformName: string, array: Int32Array): Effect;
  28473. /**
  28474. * 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)
  28475. * @param uniformName Name of the variable.
  28476. * @param array array to be set.
  28477. * @returns this effect.
  28478. */
  28479. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28480. /**
  28481. * 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)
  28482. * @param uniformName Name of the variable.
  28483. * @param array array to be set.
  28484. * @returns this effect.
  28485. */
  28486. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28487. /**
  28488. * 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)
  28489. * @param uniformName Name of the variable.
  28490. * @param array array to be set.
  28491. * @returns this effect.
  28492. */
  28493. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28494. /**
  28495. * Sets an float array on a uniform variable.
  28496. * @param uniformName Name of the variable.
  28497. * @param array array to be set.
  28498. * @returns this effect.
  28499. */
  28500. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28501. /**
  28502. * 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)
  28503. * @param uniformName Name of the variable.
  28504. * @param array array to be set.
  28505. * @returns this effect.
  28506. */
  28507. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28508. /**
  28509. * 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)
  28510. * @param uniformName Name of the variable.
  28511. * @param array array to be set.
  28512. * @returns this effect.
  28513. */
  28514. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28515. /**
  28516. * 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)
  28517. * @param uniformName Name of the variable.
  28518. * @param array array to be set.
  28519. * @returns this effect.
  28520. */
  28521. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28522. /**
  28523. * Sets an array on a uniform variable.
  28524. * @param uniformName Name of the variable.
  28525. * @param array array to be set.
  28526. * @returns this effect.
  28527. */
  28528. setArray(uniformName: string, array: number[]): Effect;
  28529. /**
  28530. * 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)
  28531. * @param uniformName Name of the variable.
  28532. * @param array array to be set.
  28533. * @returns this effect.
  28534. */
  28535. setArray2(uniformName: string, array: number[]): Effect;
  28536. /**
  28537. * 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)
  28538. * @param uniformName Name of the variable.
  28539. * @param array array to be set.
  28540. * @returns this effect.
  28541. */
  28542. setArray3(uniformName: string, array: number[]): Effect;
  28543. /**
  28544. * 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)
  28545. * @param uniformName Name of the variable.
  28546. * @param array array to be set.
  28547. * @returns this effect.
  28548. */
  28549. setArray4(uniformName: string, array: number[]): Effect;
  28550. /**
  28551. * Sets matrices on a uniform variable.
  28552. * @param uniformName Name of the variable.
  28553. * @param matrices matrices to be set.
  28554. * @returns this effect.
  28555. */
  28556. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28557. /**
  28558. * Sets matrix on a uniform variable.
  28559. * @param uniformName Name of the variable.
  28560. * @param matrix matrix to be set.
  28561. * @returns this effect.
  28562. */
  28563. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28564. /**
  28565. * 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)
  28566. * @param uniformName Name of the variable.
  28567. * @param matrix matrix to be set.
  28568. * @returns this effect.
  28569. */
  28570. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28571. /**
  28572. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28573. * @param uniformName Name of the variable.
  28574. * @param matrix matrix to be set.
  28575. * @returns this effect.
  28576. */
  28577. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28578. /**
  28579. * Sets a float on a uniform variable.
  28580. * @param uniformName Name of the variable.
  28581. * @param value value to be set.
  28582. * @returns this effect.
  28583. */
  28584. setFloat(uniformName: string, value: number): Effect;
  28585. /**
  28586. * Sets a boolean on a uniform variable.
  28587. * @param uniformName Name of the variable.
  28588. * @param bool value to be set.
  28589. * @returns this effect.
  28590. */
  28591. setBool(uniformName: string, bool: boolean): Effect;
  28592. /**
  28593. * Sets a Vector2 on a uniform variable.
  28594. * @param uniformName Name of the variable.
  28595. * @param vector2 vector2 to be set.
  28596. * @returns this effect.
  28597. */
  28598. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28599. /**
  28600. * Sets a float2 on a uniform variable.
  28601. * @param uniformName Name of the variable.
  28602. * @param x First float in float2.
  28603. * @param y Second float in float2.
  28604. * @returns this effect.
  28605. */
  28606. setFloat2(uniformName: string, x: number, y: number): Effect;
  28607. /**
  28608. * Sets a Vector3 on a uniform variable.
  28609. * @param uniformName Name of the variable.
  28610. * @param vector3 Value to be set.
  28611. * @returns this effect.
  28612. */
  28613. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28614. /**
  28615. * Sets a float3 on a uniform variable.
  28616. * @param uniformName Name of the variable.
  28617. * @param x First float in float3.
  28618. * @param y Second float in float3.
  28619. * @param z Third float in float3.
  28620. * @returns this effect.
  28621. */
  28622. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28623. /**
  28624. * Sets a Vector4 on a uniform variable.
  28625. * @param uniformName Name of the variable.
  28626. * @param vector4 Value to be set.
  28627. * @returns this effect.
  28628. */
  28629. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28630. /**
  28631. * Sets a float4 on a uniform variable.
  28632. * @param uniformName Name of the variable.
  28633. * @param x First float in float4.
  28634. * @param y Second float in float4.
  28635. * @param z Third float in float4.
  28636. * @param w Fourth float in float4.
  28637. * @returns this effect.
  28638. */
  28639. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28640. /**
  28641. * Sets a Color3 on a uniform variable.
  28642. * @param uniformName Name of the variable.
  28643. * @param color3 Value to be set.
  28644. * @returns this effect.
  28645. */
  28646. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28647. /**
  28648. * Sets a Color4 on a uniform variable.
  28649. * @param uniformName Name of the variable.
  28650. * @param color3 Value to be set.
  28651. * @param alpha Alpha value to be set.
  28652. * @returns this effect.
  28653. */
  28654. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28655. /**
  28656. * Sets a Color4 on a uniform variable
  28657. * @param uniformName defines the name of the variable
  28658. * @param color4 defines the value to be set
  28659. * @returns this effect.
  28660. */
  28661. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28662. /** Release all associated resources */
  28663. dispose(): void;
  28664. /**
  28665. * This function will add a new shader to the shader store
  28666. * @param name the name of the shader
  28667. * @param pixelShader optional pixel shader content
  28668. * @param vertexShader optional vertex shader content
  28669. */
  28670. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28671. /**
  28672. * Store of each shader (The can be looked up using effect.key)
  28673. */
  28674. static ShadersStore: {
  28675. [key: string]: string;
  28676. };
  28677. /**
  28678. * Store of each included file for a shader (The can be looked up using effect.key)
  28679. */
  28680. static IncludesShadersStore: {
  28681. [key: string]: string;
  28682. };
  28683. /**
  28684. * Resets the cache of effects.
  28685. */
  28686. static ResetCache(): void;
  28687. }
  28688. }
  28689. declare module BABYLON {
  28690. /**
  28691. * Class used to describe the capabilities of the engine relatively to the current browser
  28692. */
  28693. export class EngineCapabilities {
  28694. /** Maximum textures units per fragment shader */
  28695. maxTexturesImageUnits: number;
  28696. /** Maximum texture units per vertex shader */
  28697. maxVertexTextureImageUnits: number;
  28698. /** Maximum textures units in the entire pipeline */
  28699. maxCombinedTexturesImageUnits: number;
  28700. /** Maximum texture size */
  28701. maxTextureSize: number;
  28702. /** Maximum cube texture size */
  28703. maxCubemapTextureSize: number;
  28704. /** Maximum render texture size */
  28705. maxRenderTextureSize: number;
  28706. /** Maximum number of vertex attributes */
  28707. maxVertexAttribs: number;
  28708. /** Maximum number of varyings */
  28709. maxVaryingVectors: number;
  28710. /** Maximum number of uniforms per vertex shader */
  28711. maxVertexUniformVectors: number;
  28712. /** Maximum number of uniforms per fragment shader */
  28713. maxFragmentUniformVectors: number;
  28714. /** Defines if standard derivates (dx/dy) are supported */
  28715. standardDerivatives: boolean;
  28716. /** Defines if s3tc texture compression is supported */
  28717. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28718. /** Defines if pvrtc texture compression is supported */
  28719. pvrtc: any;
  28720. /** Defines if etc1 texture compression is supported */
  28721. etc1: any;
  28722. /** Defines if etc2 texture compression is supported */
  28723. etc2: any;
  28724. /** Defines if astc texture compression is supported */
  28725. astc: any;
  28726. /** Defines if float textures are supported */
  28727. textureFloat: boolean;
  28728. /** Defines if vertex array objects are supported */
  28729. vertexArrayObject: boolean;
  28730. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28731. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28732. /** Gets the maximum level of anisotropy supported */
  28733. maxAnisotropy: number;
  28734. /** Defines if instancing is supported */
  28735. instancedArrays: boolean;
  28736. /** Defines if 32 bits indices are supported */
  28737. uintIndices: boolean;
  28738. /** Defines if high precision shaders are supported */
  28739. highPrecisionShaderSupported: boolean;
  28740. /** Defines if depth reading in the fragment shader is supported */
  28741. fragmentDepthSupported: boolean;
  28742. /** Defines if float texture linear filtering is supported*/
  28743. textureFloatLinearFiltering: boolean;
  28744. /** Defines if rendering to float textures is supported */
  28745. textureFloatRender: boolean;
  28746. /** Defines if half float textures are supported*/
  28747. textureHalfFloat: boolean;
  28748. /** Defines if half float texture linear filtering is supported*/
  28749. textureHalfFloatLinearFiltering: boolean;
  28750. /** Defines if rendering to half float textures is supported */
  28751. textureHalfFloatRender: boolean;
  28752. /** Defines if textureLOD shader command is supported */
  28753. textureLOD: boolean;
  28754. /** Defines if draw buffers extension is supported */
  28755. drawBuffersExtension: boolean;
  28756. /** Defines if depth textures are supported */
  28757. depthTextureExtension: boolean;
  28758. /** Defines if float color buffer are supported */
  28759. colorBufferFloat: boolean;
  28760. /** Gets disjoint timer query extension (null if not supported) */
  28761. timerQuery: EXT_disjoint_timer_query;
  28762. /** Defines if timestamp can be used with timer query */
  28763. canUseTimestampForTimerQuery: boolean;
  28764. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28765. multiview: any;
  28766. /** Function used to let the system compiles shaders in background */
  28767. parallelShaderCompile: {
  28768. COMPLETION_STATUS_KHR: number;
  28769. };
  28770. /** Max number of texture samples for MSAA */
  28771. maxMSAASamples: number;
  28772. /** Defines if the blend min max extension is supported */
  28773. blendMinMax: boolean;
  28774. }
  28775. }
  28776. declare module BABYLON {
  28777. /**
  28778. * This class is used to track a performance counter which is number based.
  28779. * The user has access to many properties which give statistics of different nature.
  28780. *
  28781. * The implementer can track two kinds of Performance Counter: time and count.
  28782. * 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.
  28783. * 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.
  28784. */
  28785. export class PerfCounter {
  28786. /**
  28787. * Gets or sets a global boolean to turn on and off all the counters
  28788. */
  28789. static Enabled: boolean;
  28790. /**
  28791. * Returns the smallest value ever
  28792. */
  28793. readonly min: number;
  28794. /**
  28795. * Returns the biggest value ever
  28796. */
  28797. readonly max: number;
  28798. /**
  28799. * Returns the average value since the performance counter is running
  28800. */
  28801. readonly average: number;
  28802. /**
  28803. * Returns the average value of the last second the counter was monitored
  28804. */
  28805. readonly lastSecAverage: number;
  28806. /**
  28807. * Returns the current value
  28808. */
  28809. readonly current: number;
  28810. /**
  28811. * Gets the accumulated total
  28812. */
  28813. readonly total: number;
  28814. /**
  28815. * Gets the total value count
  28816. */
  28817. readonly count: number;
  28818. /**
  28819. * Creates a new counter
  28820. */
  28821. constructor();
  28822. /**
  28823. * Call this method to start monitoring a new frame.
  28824. * 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.
  28825. */
  28826. fetchNewFrame(): void;
  28827. /**
  28828. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28829. * @param newCount the count value to add to the monitored count
  28830. * @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.
  28831. */
  28832. addCount(newCount: number, fetchResult: boolean): void;
  28833. /**
  28834. * Start monitoring this performance counter
  28835. */
  28836. beginMonitoring(): void;
  28837. /**
  28838. * Compute the time lapsed since the previous beginMonitoring() call.
  28839. * @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
  28840. */
  28841. endMonitoring(newFrame?: boolean): void;
  28842. private _fetchResult;
  28843. private _startMonitoringTime;
  28844. private _min;
  28845. private _max;
  28846. private _average;
  28847. private _current;
  28848. private _totalValueCount;
  28849. private _totalAccumulated;
  28850. private _lastSecAverage;
  28851. private _lastSecAccumulated;
  28852. private _lastSecTime;
  28853. private _lastSecValueCount;
  28854. }
  28855. }
  28856. declare module BABYLON {
  28857. /**
  28858. * @hidden
  28859. **/
  28860. export class DepthCullingState {
  28861. private _isDepthTestDirty;
  28862. private _isDepthMaskDirty;
  28863. private _isDepthFuncDirty;
  28864. private _isCullFaceDirty;
  28865. private _isCullDirty;
  28866. private _isZOffsetDirty;
  28867. private _isFrontFaceDirty;
  28868. private _depthTest;
  28869. private _depthMask;
  28870. private _depthFunc;
  28871. private _cull;
  28872. private _cullFace;
  28873. private _zOffset;
  28874. private _frontFace;
  28875. /**
  28876. * Initializes the state.
  28877. */
  28878. constructor();
  28879. readonly isDirty: boolean;
  28880. zOffset: number;
  28881. cullFace: Nullable<number>;
  28882. cull: Nullable<boolean>;
  28883. depthFunc: Nullable<number>;
  28884. depthMask: boolean;
  28885. depthTest: boolean;
  28886. frontFace: Nullable<number>;
  28887. reset(): void;
  28888. apply(gl: WebGLRenderingContext): void;
  28889. }
  28890. }
  28891. declare module BABYLON {
  28892. /**
  28893. * @hidden
  28894. **/
  28895. export class StencilState {
  28896. /** 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 */
  28897. static readonly ALWAYS: number;
  28898. /** Passed to stencilOperation to specify that stencil value must be kept */
  28899. static readonly KEEP: number;
  28900. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28901. static readonly REPLACE: number;
  28902. private _isStencilTestDirty;
  28903. private _isStencilMaskDirty;
  28904. private _isStencilFuncDirty;
  28905. private _isStencilOpDirty;
  28906. private _stencilTest;
  28907. private _stencilMask;
  28908. private _stencilFunc;
  28909. private _stencilFuncRef;
  28910. private _stencilFuncMask;
  28911. private _stencilOpStencilFail;
  28912. private _stencilOpDepthFail;
  28913. private _stencilOpStencilDepthPass;
  28914. readonly isDirty: boolean;
  28915. stencilFunc: number;
  28916. stencilFuncRef: number;
  28917. stencilFuncMask: number;
  28918. stencilOpStencilFail: number;
  28919. stencilOpDepthFail: number;
  28920. stencilOpStencilDepthPass: number;
  28921. stencilMask: number;
  28922. stencilTest: boolean;
  28923. constructor();
  28924. reset(): void;
  28925. apply(gl: WebGLRenderingContext): void;
  28926. }
  28927. }
  28928. declare module BABYLON {
  28929. /**
  28930. * @hidden
  28931. **/
  28932. export class AlphaState {
  28933. private _isAlphaBlendDirty;
  28934. private _isBlendFunctionParametersDirty;
  28935. private _isBlendEquationParametersDirty;
  28936. private _isBlendConstantsDirty;
  28937. private _alphaBlend;
  28938. private _blendFunctionParameters;
  28939. private _blendEquationParameters;
  28940. private _blendConstants;
  28941. /**
  28942. * Initializes the state.
  28943. */
  28944. constructor();
  28945. readonly isDirty: boolean;
  28946. alphaBlend: boolean;
  28947. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28948. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28949. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28950. reset(): void;
  28951. apply(gl: WebGLRenderingContext): void;
  28952. }
  28953. }
  28954. declare module BABYLON {
  28955. /** @hidden */
  28956. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28957. attributeProcessor(attribute: string): string;
  28958. varyingProcessor(varying: string, isFragment: boolean): string;
  28959. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28960. }
  28961. }
  28962. declare module BABYLON {
  28963. /**
  28964. * Interface for attribute information associated with buffer instanciation
  28965. */
  28966. export class InstancingAttributeInfo {
  28967. /**
  28968. * Index/offset of the attribute in the vertex shader
  28969. */
  28970. index: number;
  28971. /**
  28972. * size of the attribute, 1, 2, 3 or 4
  28973. */
  28974. attributeSize: number;
  28975. /**
  28976. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28977. * default is FLOAT
  28978. */
  28979. attribyteType: number;
  28980. /**
  28981. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28982. */
  28983. normalized: boolean;
  28984. /**
  28985. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28986. */
  28987. offset: number;
  28988. /**
  28989. * Name of the GLSL attribute, for debugging purpose only
  28990. */
  28991. attributeName: string;
  28992. }
  28993. }
  28994. declare module BABYLON {
  28995. interface ThinEngine {
  28996. /**
  28997. * Update a video texture
  28998. * @param texture defines the texture to update
  28999. * @param video defines the video element to use
  29000. * @param invertY defines if data must be stored with Y axis inverted
  29001. */
  29002. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29003. }
  29004. }
  29005. declare module BABYLON {
  29006. /**
  29007. * Settings for finer control over video usage
  29008. */
  29009. export interface VideoTextureSettings {
  29010. /**
  29011. * Applies `autoplay` to video, if specified
  29012. */
  29013. autoPlay?: boolean;
  29014. /**
  29015. * Applies `loop` to video, if specified
  29016. */
  29017. loop?: boolean;
  29018. /**
  29019. * Automatically updates internal texture from video at every frame in the render loop
  29020. */
  29021. autoUpdateTexture: boolean;
  29022. /**
  29023. * Image src displayed during the video loading or until the user interacts with the video.
  29024. */
  29025. poster?: string;
  29026. }
  29027. /**
  29028. * If you want to display a video in your scene, this is the special texture for that.
  29029. * This special texture works similar to other textures, with the exception of a few parameters.
  29030. * @see https://doc.babylonjs.com/how_to/video_texture
  29031. */
  29032. export class VideoTexture extends Texture {
  29033. /**
  29034. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29035. */
  29036. readonly autoUpdateTexture: boolean;
  29037. /**
  29038. * The video instance used by the texture internally
  29039. */
  29040. readonly video: HTMLVideoElement;
  29041. private _onUserActionRequestedObservable;
  29042. /**
  29043. * Event triggerd when a dom action is required by the user to play the video.
  29044. * This happens due to recent changes in browser policies preventing video to auto start.
  29045. */
  29046. readonly onUserActionRequestedObservable: Observable<Texture>;
  29047. private _generateMipMaps;
  29048. private _engine;
  29049. private _stillImageCaptured;
  29050. private _displayingPosterTexture;
  29051. private _settings;
  29052. private _createInternalTextureOnEvent;
  29053. private _frameId;
  29054. /**
  29055. * Creates a video texture.
  29056. * If you want to display a video in your scene, this is the special texture for that.
  29057. * This special texture works similar to other textures, with the exception of a few parameters.
  29058. * @see https://doc.babylonjs.com/how_to/video_texture
  29059. * @param name optional name, will detect from video source, if not defined
  29060. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29061. * @param scene is obviously the current scene.
  29062. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29063. * @param invertY is false by default but can be used to invert video on Y axis
  29064. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29065. * @param settings allows finer control over video usage
  29066. */
  29067. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29068. private _getName;
  29069. private _getVideo;
  29070. private _createInternalTexture;
  29071. private reset;
  29072. /**
  29073. * @hidden Internal method to initiate `update`.
  29074. */
  29075. _rebuild(): void;
  29076. /**
  29077. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29078. */
  29079. update(): void;
  29080. /**
  29081. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29082. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29083. */
  29084. updateTexture(isVisible: boolean): void;
  29085. protected _updateInternalTexture: () => void;
  29086. /**
  29087. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29088. * @param url New url.
  29089. */
  29090. updateURL(url: string): void;
  29091. /**
  29092. * Dispose the texture and release its associated resources.
  29093. */
  29094. dispose(): void;
  29095. /**
  29096. * Creates a video texture straight from a stream.
  29097. * @param scene Define the scene the texture should be created in
  29098. * @param stream Define the stream the texture should be created from
  29099. * @returns The created video texture as a promise
  29100. */
  29101. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29102. /**
  29103. * Creates a video texture straight from your WebCam video feed.
  29104. * @param scene Define the scene the texture should be created in
  29105. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29106. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29107. * @returns The created video texture as a promise
  29108. */
  29109. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29110. minWidth: number;
  29111. maxWidth: number;
  29112. minHeight: number;
  29113. maxHeight: number;
  29114. deviceId: string;
  29115. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29116. /**
  29117. * Creates a video texture straight from your WebCam video feed.
  29118. * @param scene Define the scene the texture should be created in
  29119. * @param onReady Define a callback to triggered once the texture will be ready
  29120. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29121. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29122. */
  29123. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29124. minWidth: number;
  29125. maxWidth: number;
  29126. minHeight: number;
  29127. maxHeight: number;
  29128. deviceId: string;
  29129. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29130. }
  29131. }
  29132. declare module BABYLON {
  29133. /**
  29134. * Defines the interface used by objects working like Scene
  29135. * @hidden
  29136. */
  29137. interface ISceneLike {
  29138. _addPendingData(data: any): void;
  29139. _removePendingData(data: any): void;
  29140. offlineProvider: IOfflineProvider;
  29141. }
  29142. /** Interface defining initialization parameters for Engine class */
  29143. export interface EngineOptions extends WebGLContextAttributes {
  29144. /**
  29145. * Defines if the engine should no exceed a specified device ratio
  29146. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29147. */
  29148. limitDeviceRatio?: number;
  29149. /**
  29150. * Defines if webvr should be enabled automatically
  29151. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29152. */
  29153. autoEnableWebVR?: boolean;
  29154. /**
  29155. * Defines if webgl2 should be turned off even if supported
  29156. * @see http://doc.babylonjs.com/features/webgl2
  29157. */
  29158. disableWebGL2Support?: boolean;
  29159. /**
  29160. * Defines if webaudio should be initialized as well
  29161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29162. */
  29163. audioEngine?: boolean;
  29164. /**
  29165. * Defines if animations should run using a deterministic lock step
  29166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29167. */
  29168. deterministicLockstep?: boolean;
  29169. /** Defines the maximum steps to use with deterministic lock step mode */
  29170. lockstepMaxSteps?: number;
  29171. /**
  29172. * Defines that engine should ignore context lost events
  29173. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29174. */
  29175. doNotHandleContextLost?: boolean;
  29176. /**
  29177. * Defines that engine should ignore modifying touch action attribute and style
  29178. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29179. */
  29180. doNotHandleTouchAction?: boolean;
  29181. /**
  29182. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29183. */
  29184. useHighPrecisionFloats?: boolean;
  29185. }
  29186. /**
  29187. * The base engine class (root of all engines)
  29188. */
  29189. export class ThinEngine {
  29190. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29191. static ExceptionList: ({
  29192. key: string;
  29193. capture: string;
  29194. captureConstraint: number;
  29195. targets: string[];
  29196. } | {
  29197. key: string;
  29198. capture: null;
  29199. captureConstraint: null;
  29200. targets: string[];
  29201. })[];
  29202. /** @hidden */
  29203. static _TextureLoaders: IInternalTextureLoader[];
  29204. /**
  29205. * Returns the current npm package of the sdk
  29206. */
  29207. static readonly NpmPackage: string;
  29208. /**
  29209. * Returns the current version of the framework
  29210. */
  29211. static readonly Version: string;
  29212. /**
  29213. * Returns a string describing the current engine
  29214. */
  29215. readonly description: string;
  29216. /**
  29217. * Gets or sets the epsilon value used by collision engine
  29218. */
  29219. static CollisionsEpsilon: number;
  29220. /**
  29221. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29222. */
  29223. static ShadersRepository: string;
  29224. /** @hidden */
  29225. _shaderProcessor: IShaderProcessor;
  29226. /**
  29227. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29228. */
  29229. forcePOTTextures: boolean;
  29230. /**
  29231. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29232. */
  29233. isFullscreen: boolean;
  29234. /**
  29235. * Gets a boolean indicating if the pointer is currently locked
  29236. */
  29237. isPointerLock: boolean;
  29238. /**
  29239. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29240. */
  29241. cullBackFaces: boolean;
  29242. /**
  29243. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29244. */
  29245. renderEvenInBackground: boolean;
  29246. /**
  29247. * Gets or sets a boolean indicating that cache can be kept between frames
  29248. */
  29249. preventCacheWipeBetweenFrames: boolean;
  29250. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29251. validateShaderPrograms: boolean;
  29252. /**
  29253. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29254. */
  29255. disableUniformBuffers: boolean;
  29256. /** @hidden */
  29257. _uniformBuffers: UniformBuffer[];
  29258. /**
  29259. * Gets a boolean indicating that the engine supports uniform buffers
  29260. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29261. */
  29262. readonly supportsUniformBuffers: boolean;
  29263. /** @hidden */
  29264. _gl: WebGLRenderingContext;
  29265. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29266. protected _windowIsBackground: boolean;
  29267. protected _webGLVersion: number;
  29268. protected _highPrecisionShadersAllowed: boolean;
  29269. /** @hidden */
  29270. readonly _shouldUseHighPrecisionShader: boolean;
  29271. /**
  29272. * Gets a boolean indicating that only power of 2 textures are supported
  29273. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29274. */
  29275. readonly needPOTTextures: boolean;
  29276. /** @hidden */
  29277. _badOS: boolean;
  29278. /** @hidden */
  29279. _badDesktopOS: boolean;
  29280. private _hardwareScalingLevel;
  29281. /** @hidden */
  29282. _caps: EngineCapabilities;
  29283. private _isStencilEnable;
  29284. protected _colorWrite: boolean;
  29285. /** @hidden */
  29286. _drawCalls: PerfCounter;
  29287. private _glVersion;
  29288. private _glRenderer;
  29289. private _glVendor;
  29290. /** @hidden */
  29291. _videoTextureSupported: boolean;
  29292. protected _renderingQueueLaunched: boolean;
  29293. protected _activeRenderLoops: (() => void)[];
  29294. /**
  29295. * Observable signaled when a context lost event is raised
  29296. */
  29297. onContextLostObservable: Observable<ThinEngine>;
  29298. /**
  29299. * Observable signaled when a context restored event is raised
  29300. */
  29301. onContextRestoredObservable: Observable<ThinEngine>;
  29302. private _onContextLost;
  29303. private _onContextRestored;
  29304. protected _contextWasLost: boolean;
  29305. /** @hidden */
  29306. _doNotHandleContextLost: boolean;
  29307. /**
  29308. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29310. */
  29311. doNotHandleContextLost: boolean;
  29312. /**
  29313. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29314. */
  29315. disableVertexArrayObjects: boolean;
  29316. /** @hidden */
  29317. protected _depthCullingState: DepthCullingState;
  29318. /** @hidden */
  29319. protected _stencilState: StencilState;
  29320. /** @hidden */
  29321. protected _alphaState: AlphaState;
  29322. /** @hidden */
  29323. _internalTexturesCache: InternalTexture[];
  29324. /** @hidden */
  29325. protected _activeChannel: number;
  29326. private _currentTextureChannel;
  29327. /** @hidden */
  29328. protected _boundTexturesCache: {
  29329. [key: string]: Nullable<InternalTexture>;
  29330. };
  29331. /** @hidden */
  29332. protected _currentEffect: Nullable<Effect>;
  29333. /** @hidden */
  29334. protected _currentProgram: Nullable<WebGLProgram>;
  29335. private _compiledEffects;
  29336. private _vertexAttribArraysEnabled;
  29337. /** @hidden */
  29338. protected _cachedViewport: Nullable<IViewportLike>;
  29339. private _cachedVertexArrayObject;
  29340. /** @hidden */
  29341. protected _cachedVertexBuffers: any;
  29342. /** @hidden */
  29343. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29344. /** @hidden */
  29345. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29346. /** @hidden */
  29347. _currentRenderTarget: Nullable<InternalTexture>;
  29348. private _uintIndicesCurrentlySet;
  29349. private _currentBoundBuffer;
  29350. /** @hidden */
  29351. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29352. private _currentBufferPointers;
  29353. private _currentInstanceLocations;
  29354. private _currentInstanceBuffers;
  29355. private _textureUnits;
  29356. /** @hidden */
  29357. _workingCanvas: Nullable<HTMLCanvasElement>;
  29358. /** @hidden */
  29359. _workingContext: Nullable<CanvasRenderingContext2D>;
  29360. /** @hidden */
  29361. _bindedRenderFunction: any;
  29362. private _vaoRecordInProgress;
  29363. private _mustWipeVertexAttributes;
  29364. private _emptyTexture;
  29365. private _emptyCubeTexture;
  29366. private _emptyTexture3D;
  29367. /** @hidden */
  29368. _frameHandler: number;
  29369. private _nextFreeTextureSlots;
  29370. private _maxSimultaneousTextures;
  29371. private _activeRequests;
  29372. private _texturesSupported;
  29373. /** @hidden */
  29374. _textureFormatInUse: Nullable<string>;
  29375. protected readonly _supportsHardwareTextureRescaling: boolean;
  29376. /**
  29377. * Gets the list of texture formats supported
  29378. */
  29379. readonly texturesSupported: Array<string>;
  29380. /**
  29381. * Gets the list of texture formats in use
  29382. */
  29383. readonly textureFormatInUse: Nullable<string>;
  29384. /**
  29385. * Gets the current viewport
  29386. */
  29387. readonly currentViewport: Nullable<IViewportLike>;
  29388. /**
  29389. * Gets the default empty texture
  29390. */
  29391. readonly emptyTexture: InternalTexture;
  29392. /**
  29393. * Gets the default empty 3D texture
  29394. */
  29395. readonly emptyTexture3D: InternalTexture;
  29396. /**
  29397. * Gets the default empty cube texture
  29398. */
  29399. readonly emptyCubeTexture: InternalTexture;
  29400. /**
  29401. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29402. */
  29403. readonly premultipliedAlpha: boolean;
  29404. /**
  29405. * Creates a new engine
  29406. * @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
  29407. * @param antialias defines enable antialiasing (default: false)
  29408. * @param options defines further options to be sent to the getContext() function
  29409. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29410. */
  29411. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29412. private _rebuildInternalTextures;
  29413. private _rebuildEffects;
  29414. /**
  29415. * Gets a boolean indicating if all created effects are ready
  29416. * @returns true if all effects are ready
  29417. */
  29418. areAllEffectsReady(): boolean;
  29419. protected _rebuildBuffers(): void;
  29420. private _initGLContext;
  29421. /**
  29422. * Gets version of the current webGL context
  29423. */
  29424. readonly webGLVersion: number;
  29425. /**
  29426. * Gets a string idenfifying the name of the class
  29427. * @returns "Engine" string
  29428. */
  29429. getClassName(): string;
  29430. /**
  29431. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29432. */
  29433. readonly isStencilEnable: boolean;
  29434. /** @hidden */
  29435. _prepareWorkingCanvas(): void;
  29436. /**
  29437. * Reset the texture cache to empty state
  29438. */
  29439. resetTextureCache(): void;
  29440. /**
  29441. * Gets an object containing information about the current webGL context
  29442. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29443. */
  29444. getGlInfo(): {
  29445. vendor: string;
  29446. renderer: string;
  29447. version: string;
  29448. };
  29449. /**
  29450. * Defines the hardware scaling level.
  29451. * By default the hardware scaling level is computed from the window device ratio.
  29452. * 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.
  29453. * @param level defines the level to use
  29454. */
  29455. setHardwareScalingLevel(level: number): void;
  29456. /**
  29457. * Gets the current hardware scaling level.
  29458. * By default the hardware scaling level is computed from the window device ratio.
  29459. * 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.
  29460. * @returns a number indicating the current hardware scaling level
  29461. */
  29462. getHardwareScalingLevel(): number;
  29463. /**
  29464. * Gets the list of loaded textures
  29465. * @returns an array containing all loaded textures
  29466. */
  29467. getLoadedTexturesCache(): InternalTexture[];
  29468. /**
  29469. * Gets the object containing all engine capabilities
  29470. * @returns the EngineCapabilities object
  29471. */
  29472. getCaps(): EngineCapabilities;
  29473. /**
  29474. * stop executing a render loop function and remove it from the execution array
  29475. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29476. */
  29477. stopRenderLoop(renderFunction?: () => void): void;
  29478. /** @hidden */
  29479. _renderLoop(): void;
  29480. /**
  29481. * Gets the HTML canvas attached with the current webGL context
  29482. * @returns a HTML canvas
  29483. */
  29484. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29485. /**
  29486. * Gets host window
  29487. * @returns the host window object
  29488. */
  29489. getHostWindow(): Window;
  29490. /**
  29491. * Gets the current render width
  29492. * @param useScreen defines if screen size must be used (or the current render target if any)
  29493. * @returns a number defining the current render width
  29494. */
  29495. getRenderWidth(useScreen?: boolean): number;
  29496. /**
  29497. * Gets the current render height
  29498. * @param useScreen defines if screen size must be used (or the current render target if any)
  29499. * @returns a number defining the current render height
  29500. */
  29501. getRenderHeight(useScreen?: boolean): number;
  29502. /**
  29503. * Can be used to override the current requestAnimationFrame requester.
  29504. * @hidden
  29505. */
  29506. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29507. /**
  29508. * Register and execute a render loop. The engine can have more than one render function
  29509. * @param renderFunction defines the function to continuously execute
  29510. */
  29511. runRenderLoop(renderFunction: () => void): void;
  29512. /**
  29513. * Clear the current render buffer or the current render target (if any is set up)
  29514. * @param color defines the color to use
  29515. * @param backBuffer defines if the back buffer must be cleared
  29516. * @param depth defines if the depth buffer must be cleared
  29517. * @param stencil defines if the stencil buffer must be cleared
  29518. */
  29519. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29520. private _viewportCached;
  29521. /** @hidden */
  29522. _viewport(x: number, y: number, width: number, height: number): void;
  29523. /**
  29524. * Set the WebGL's viewport
  29525. * @param viewport defines the viewport element to be used
  29526. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29527. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29528. */
  29529. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29530. /**
  29531. * Begin a new frame
  29532. */
  29533. beginFrame(): void;
  29534. /**
  29535. * Enf the current frame
  29536. */
  29537. endFrame(): void;
  29538. /**
  29539. * Resize the view according to the canvas' size
  29540. */
  29541. resize(): void;
  29542. /**
  29543. * Force a specific size of the canvas
  29544. * @param width defines the new canvas' width
  29545. * @param height defines the new canvas' height
  29546. */
  29547. setSize(width: number, height: number): void;
  29548. /**
  29549. * Binds the frame buffer to the specified texture.
  29550. * @param texture The texture to render to or null for the default canvas
  29551. * @param faceIndex The face of the texture to render to in case of cube texture
  29552. * @param requiredWidth The width of the target to render to
  29553. * @param requiredHeight The height of the target to render to
  29554. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29555. * @param depthStencilTexture The depth stencil texture to use to render
  29556. * @param lodLevel defines le lod level to bind to the frame buffer
  29557. */
  29558. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29559. /** @hidden */
  29560. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29561. /**
  29562. * Unbind the current render target texture from the webGL context
  29563. * @param texture defines the render target texture to unbind
  29564. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29565. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29566. */
  29567. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29568. /**
  29569. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29570. */
  29571. flushFramebuffer(): void;
  29572. /**
  29573. * Unbind the current render target and bind the default framebuffer
  29574. */
  29575. restoreDefaultFramebuffer(): void;
  29576. private _resetVertexBufferBinding;
  29577. /**
  29578. * Creates a vertex buffer
  29579. * @param data the data for the vertex buffer
  29580. * @returns the new WebGL static buffer
  29581. */
  29582. createVertexBuffer(data: DataArray): DataBuffer;
  29583. private _createVertexBuffer;
  29584. /**
  29585. * Creates a dynamic vertex buffer
  29586. * @param data the data for the dynamic vertex buffer
  29587. * @returns the new WebGL dynamic buffer
  29588. */
  29589. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29590. /**
  29591. * Update a dynamic index buffer
  29592. * @param indexBuffer defines the target index buffer
  29593. * @param indices defines the data to update
  29594. * @param offset defines the offset in the target index buffer where update should start
  29595. */
  29596. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29597. /**
  29598. * Updates a dynamic vertex buffer.
  29599. * @param vertexBuffer the vertex buffer to update
  29600. * @param data the data used to update the vertex buffer
  29601. * @param byteOffset the byte offset of the data
  29602. * @param byteLength the byte length of the data
  29603. */
  29604. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29605. private _resetIndexBufferBinding;
  29606. /**
  29607. * Creates a new index buffer
  29608. * @param indices defines the content of the index buffer
  29609. * @param updatable defines if the index buffer must be updatable
  29610. * @returns a new webGL buffer
  29611. */
  29612. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29613. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29614. /**
  29615. * Bind a webGL buffer to the webGL context
  29616. * @param buffer defines the buffer to bind
  29617. */
  29618. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29619. private bindIndexBuffer;
  29620. private bindBuffer;
  29621. /**
  29622. * update the bound buffer with the given data
  29623. * @param data defines the data to update
  29624. */
  29625. updateArrayBuffer(data: Float32Array): void;
  29626. private _vertexAttribPointer;
  29627. private _bindIndexBufferWithCache;
  29628. private _bindVertexBuffersAttributes;
  29629. /**
  29630. * Records a vertex array object
  29631. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29632. * @param vertexBuffers defines the list of vertex buffers to store
  29633. * @param indexBuffer defines the index buffer to store
  29634. * @param effect defines the effect to store
  29635. * @returns the new vertex array object
  29636. */
  29637. recordVertexArrayObject(vertexBuffers: {
  29638. [key: string]: VertexBuffer;
  29639. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29640. /**
  29641. * Bind a specific vertex array object
  29642. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29643. * @param vertexArrayObject defines the vertex array object to bind
  29644. * @param indexBuffer defines the index buffer to bind
  29645. */
  29646. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29647. /**
  29648. * Bind webGl buffers directly to the webGL context
  29649. * @param vertexBuffer defines the vertex buffer to bind
  29650. * @param indexBuffer defines the index buffer to bind
  29651. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29652. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29653. * @param effect defines the effect associated with the vertex buffer
  29654. */
  29655. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29656. private _unbindVertexArrayObject;
  29657. /**
  29658. * Bind a list of vertex buffers to the webGL context
  29659. * @param vertexBuffers defines the list of vertex buffers to bind
  29660. * @param indexBuffer defines the index buffer to bind
  29661. * @param effect defines the effect associated with the vertex buffers
  29662. */
  29663. bindBuffers(vertexBuffers: {
  29664. [key: string]: Nullable<VertexBuffer>;
  29665. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29666. /**
  29667. * Unbind all instance attributes
  29668. */
  29669. unbindInstanceAttributes(): void;
  29670. /**
  29671. * Release and free the memory of a vertex array object
  29672. * @param vao defines the vertex array object to delete
  29673. */
  29674. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29675. /** @hidden */
  29676. _releaseBuffer(buffer: DataBuffer): boolean;
  29677. protected _deleteBuffer(buffer: DataBuffer): void;
  29678. /**
  29679. * Creates a webGL buffer to use with instanciation
  29680. * @param capacity defines the size of the buffer
  29681. * @returns the webGL buffer
  29682. */
  29683. createInstancesBuffer(capacity: number): DataBuffer;
  29684. /**
  29685. * Delete a webGL buffer used with instanciation
  29686. * @param buffer defines the webGL buffer to delete
  29687. */
  29688. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29689. /**
  29690. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29691. * @param instancesBuffer defines the webGL buffer to update and bind
  29692. * @param data defines the data to store in the buffer
  29693. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29694. */
  29695. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29696. /**
  29697. * Apply all cached states (depth, culling, stencil and alpha)
  29698. */
  29699. applyStates(): void;
  29700. /**
  29701. * Send a draw order
  29702. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29703. * @param indexStart defines the starting index
  29704. * @param indexCount defines the number of index to draw
  29705. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29706. */
  29707. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29708. /**
  29709. * Draw a list of points
  29710. * @param verticesStart defines the index of first vertex to draw
  29711. * @param verticesCount defines the count of vertices to draw
  29712. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29713. */
  29714. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29715. /**
  29716. * Draw a list of unindexed primitives
  29717. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29718. * @param verticesStart defines the index of first vertex to draw
  29719. * @param verticesCount defines the count of vertices to draw
  29720. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29721. */
  29722. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29723. /**
  29724. * Draw a list of indexed primitives
  29725. * @param fillMode defines the primitive to use
  29726. * @param indexStart defines the starting index
  29727. * @param indexCount defines the number of index to draw
  29728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29729. */
  29730. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29731. /**
  29732. * Draw a list of unindexed primitives
  29733. * @param fillMode defines the primitive to use
  29734. * @param verticesStart defines the index of first vertex to draw
  29735. * @param verticesCount defines the count of vertices to draw
  29736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29737. */
  29738. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29739. private _drawMode;
  29740. /** @hidden */
  29741. _releaseEffect(effect: Effect): void;
  29742. /** @hidden */
  29743. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29744. /**
  29745. * Create a new effect (used to store vertex/fragment shaders)
  29746. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29747. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29748. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29749. * @param samplers defines an array of string used to represent textures
  29750. * @param defines defines the string containing the defines to use to compile the shaders
  29751. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29752. * @param onCompiled defines a function to call when the effect creation is successful
  29753. * @param onError defines a function to call when the effect creation has failed
  29754. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29755. * @returns the new Effect
  29756. */
  29757. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29758. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29759. private _compileShader;
  29760. private _compileRawShader;
  29761. /**
  29762. * Directly creates a webGL program
  29763. * @param pipelineContext defines the pipeline context to attach to
  29764. * @param vertexCode defines the vertex shader code to use
  29765. * @param fragmentCode defines the fragment shader code to use
  29766. * @param context defines the webGL context to use (if not set, the current one will be used)
  29767. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29768. * @returns the new webGL program
  29769. */
  29770. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29771. /**
  29772. * Creates a webGL program
  29773. * @param pipelineContext defines the pipeline context to attach to
  29774. * @param vertexCode defines the vertex shader code to use
  29775. * @param fragmentCode defines the fragment shader code to use
  29776. * @param defines defines the string containing the defines to use to compile the shaders
  29777. * @param context defines the webGL context to use (if not set, the current one will be used)
  29778. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29779. * @returns the new webGL program
  29780. */
  29781. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29782. /**
  29783. * Creates a new pipeline context
  29784. * @returns the new pipeline
  29785. */
  29786. createPipelineContext(): IPipelineContext;
  29787. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29788. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29789. /** @hidden */
  29790. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29791. /** @hidden */
  29792. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29793. /** @hidden */
  29794. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29795. /**
  29796. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29797. * @param pipelineContext defines the pipeline context to use
  29798. * @param uniformsNames defines the list of uniform names
  29799. * @returns an array of webGL uniform locations
  29800. */
  29801. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29802. /**
  29803. * Gets the lsit of active attributes for a given webGL program
  29804. * @param pipelineContext defines the pipeline context to use
  29805. * @param attributesNames defines the list of attribute names to get
  29806. * @returns an array of indices indicating the offset of each attribute
  29807. */
  29808. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29809. /**
  29810. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29811. * @param effect defines the effect to activate
  29812. */
  29813. enableEffect(effect: Nullable<Effect>): void;
  29814. /**
  29815. * Set the value of an uniform to an array of int32
  29816. * @param uniform defines the webGL uniform location where to store the value
  29817. * @param array defines the array of int32 to store
  29818. */
  29819. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29820. /**
  29821. * Set the value of an uniform to an array of int32 (stored as vec2)
  29822. * @param uniform defines the webGL uniform location where to store the value
  29823. * @param array defines the array of int32 to store
  29824. */
  29825. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29826. /**
  29827. * Set the value of an uniform to an array of int32 (stored as vec3)
  29828. * @param uniform defines the webGL uniform location where to store the value
  29829. * @param array defines the array of int32 to store
  29830. */
  29831. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29832. /**
  29833. * Set the value of an uniform to an array of int32 (stored as vec4)
  29834. * @param uniform defines the webGL uniform location where to store the value
  29835. * @param array defines the array of int32 to store
  29836. */
  29837. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29838. /**
  29839. * Set the value of an uniform to an array of float32
  29840. * @param uniform defines the webGL uniform location where to store the value
  29841. * @param array defines the array of float32 to store
  29842. */
  29843. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29844. /**
  29845. * Set the value of an uniform to an array of float32 (stored as vec2)
  29846. * @param uniform defines the webGL uniform location where to store the value
  29847. * @param array defines the array of float32 to store
  29848. */
  29849. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29850. /**
  29851. * Set the value of an uniform to an array of float32 (stored as vec3)
  29852. * @param uniform defines the webGL uniform location where to store the value
  29853. * @param array defines the array of float32 to store
  29854. */
  29855. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29856. /**
  29857. * Set the value of an uniform to an array of float32 (stored as vec4)
  29858. * @param uniform defines the webGL uniform location where to store the value
  29859. * @param array defines the array of float32 to store
  29860. */
  29861. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29862. /**
  29863. * Set the value of an uniform to an array of number
  29864. * @param uniform defines the webGL uniform location where to store the value
  29865. * @param array defines the array of number to store
  29866. */
  29867. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29868. /**
  29869. * Set the value of an uniform to an array of number (stored as vec2)
  29870. * @param uniform defines the webGL uniform location where to store the value
  29871. * @param array defines the array of number to store
  29872. */
  29873. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29874. /**
  29875. * Set the value of an uniform to an array of number (stored as vec3)
  29876. * @param uniform defines the webGL uniform location where to store the value
  29877. * @param array defines the array of number to store
  29878. */
  29879. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29880. /**
  29881. * Set the value of an uniform to an array of number (stored as vec4)
  29882. * @param uniform defines the webGL uniform location where to store the value
  29883. * @param array defines the array of number to store
  29884. */
  29885. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29886. /**
  29887. * Set the value of an uniform to an array of float32 (stored as matrices)
  29888. * @param uniform defines the webGL uniform location where to store the value
  29889. * @param matrices defines the array of float32 to store
  29890. */
  29891. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29892. /**
  29893. * Set the value of an uniform to a matrix (3x3)
  29894. * @param uniform defines the webGL uniform location where to store the value
  29895. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29896. */
  29897. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29898. /**
  29899. * Set the value of an uniform to a matrix (2x2)
  29900. * @param uniform defines the webGL uniform location where to store the value
  29901. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29902. */
  29903. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29904. /**
  29905. * Set the value of an uniform to a number (int)
  29906. * @param uniform defines the webGL uniform location where to store the value
  29907. * @param value defines the int number to store
  29908. */
  29909. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29910. /**
  29911. * Set the value of an uniform to a number (float)
  29912. * @param uniform defines the webGL uniform location where to store the value
  29913. * @param value defines the float number to store
  29914. */
  29915. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29916. /**
  29917. * Set the value of an uniform to a vec2
  29918. * @param uniform defines the webGL uniform location where to store the value
  29919. * @param x defines the 1st component of the value
  29920. * @param y defines the 2nd component of the value
  29921. */
  29922. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29923. /**
  29924. * Set the value of an uniform to a vec3
  29925. * @param uniform defines the webGL uniform location where to store the value
  29926. * @param x defines the 1st component of the value
  29927. * @param y defines the 2nd component of the value
  29928. * @param z defines the 3rd component of the value
  29929. */
  29930. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29931. /**
  29932. * Set the value of an uniform to a boolean
  29933. * @param uniform defines the webGL uniform location where to store the value
  29934. * @param bool defines the boolean to store
  29935. */
  29936. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29937. /**
  29938. * Set the value of an uniform to a vec4
  29939. * @param uniform defines the webGL uniform location where to store the value
  29940. * @param x defines the 1st component of the value
  29941. * @param y defines the 2nd component of the value
  29942. * @param z defines the 3rd component of the value
  29943. * @param w defines the 4th component of the value
  29944. */
  29945. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29946. /**
  29947. * Sets a Color4 on a uniform variable
  29948. * @param uniform defines the uniform location
  29949. * @param color4 defines the value to be set
  29950. */
  29951. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29952. /**
  29953. * Gets the depth culling state manager
  29954. */
  29955. readonly depthCullingState: DepthCullingState;
  29956. /**
  29957. * Gets the alpha state manager
  29958. */
  29959. readonly alphaState: AlphaState;
  29960. /**
  29961. * Gets the stencil state manager
  29962. */
  29963. readonly stencilState: StencilState;
  29964. /**
  29965. * Clears the list of texture accessible through engine.
  29966. * This can help preventing texture load conflict due to name collision.
  29967. */
  29968. clearInternalTexturesCache(): void;
  29969. /**
  29970. * Force the entire cache to be cleared
  29971. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29972. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29973. */
  29974. wipeCaches(bruteForce?: boolean): void;
  29975. /**
  29976. * Set the compressed texture format to use, based on the formats you have, and the formats
  29977. * supported by the hardware / browser.
  29978. *
  29979. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29980. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29981. * to API arguments needed to compressed textures. This puts the burden on the container
  29982. * generator to house the arcane code for determining these for current & future formats.
  29983. *
  29984. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29985. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29986. *
  29987. * Note: The result of this call is not taken into account when a texture is base64.
  29988. *
  29989. * @param formatsAvailable defines the list of those format families you have created
  29990. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29991. *
  29992. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29993. * @returns The extension selected.
  29994. */
  29995. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29996. /** @hidden */
  29997. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29998. min: number;
  29999. mag: number;
  30000. };
  30001. /** @hidden */
  30002. _createTexture(): WebGLTexture;
  30003. /**
  30004. * Usually called from Texture.ts.
  30005. * Passed information to create a WebGLTexture
  30006. * @param urlArg defines a value which contains one of the following:
  30007. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30008. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30009. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30010. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30011. * @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)
  30012. * @param scene needed for loading to the correct scene
  30013. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30014. * @param onLoad optional callback to be called upon successful completion
  30015. * @param onError optional callback to be called upon failure
  30016. * @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
  30017. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30018. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30019. * @param forcedExtension defines the extension to use to pick the right loader
  30020. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30021. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30022. */
  30023. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30024. /**
  30025. * @hidden
  30026. */
  30027. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30028. /**
  30029. * Creates a raw texture
  30030. * @param data defines the data to store in the texture
  30031. * @param width defines the width of the texture
  30032. * @param height defines the height of the texture
  30033. * @param format defines the format of the data
  30034. * @param generateMipMaps defines if the engine should generate the mip levels
  30035. * @param invertY defines if data must be stored with Y axis inverted
  30036. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30037. * @param compression defines the compression used (null by default)
  30038. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30039. * @returns the raw texture inside an InternalTexture
  30040. */
  30041. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30042. /**
  30043. * Creates a new raw cube texture
  30044. * @param data defines the array of data to use to create each face
  30045. * @param size defines the size of the textures
  30046. * @param format defines the format of the data
  30047. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30048. * @param generateMipMaps defines if the engine should generate the mip levels
  30049. * @param invertY defines if data must be stored with Y axis inverted
  30050. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30051. * @param compression defines the compression used (null by default)
  30052. * @returns the cube texture as an InternalTexture
  30053. */
  30054. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30055. /**
  30056. * Creates a new raw 3D texture
  30057. * @param data defines the data used to create the texture
  30058. * @param width defines the width of the texture
  30059. * @param height defines the height of the texture
  30060. * @param depth defines the depth of the texture
  30061. * @param format defines the format of the texture
  30062. * @param generateMipMaps defines if the engine must generate mip levels
  30063. * @param invertY defines if data must be stored with Y axis inverted
  30064. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30065. * @param compression defines the compressed used (can be null)
  30066. * @param textureType defines the compressed used (can be null)
  30067. * @returns a new raw 3D texture (stored in an InternalTexture)
  30068. */
  30069. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30070. private _unpackFlipYCached;
  30071. /**
  30072. * In case you are sharing the context with other applications, it might
  30073. * be interested to not cache the unpack flip y state to ensure a consistent
  30074. * value would be set.
  30075. */
  30076. enableUnpackFlipYCached: boolean;
  30077. /** @hidden */
  30078. _unpackFlipY(value: boolean): void;
  30079. /** @hidden */
  30080. _getUnpackAlignement(): number;
  30081. /**
  30082. * Update the sampling mode of a given texture
  30083. * @param samplingMode defines the required sampling mode
  30084. * @param texture defines the texture to update
  30085. */
  30086. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30087. /**
  30088. * Updates a depth texture Comparison Mode and Function.
  30089. * If the comparison Function is equal to 0, the mode will be set to none.
  30090. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30091. * @param texture The texture to set the comparison function for
  30092. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30093. */
  30094. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30095. /** @hidden */
  30096. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30097. width: number;
  30098. height: number;
  30099. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30100. /**
  30101. * Creates a depth stencil texture.
  30102. * This is only available in WebGL 2 or with the depth texture extension available.
  30103. * @param size The size of face edge in the texture.
  30104. * @param options The options defining the texture.
  30105. * @returns The texture
  30106. */
  30107. createDepthStencilTexture(size: number | {
  30108. width: number;
  30109. height: number;
  30110. }, options: DepthTextureCreationOptions): InternalTexture;
  30111. /**
  30112. * Creates a depth stencil texture.
  30113. * This is only available in WebGL 2 or with the depth texture extension available.
  30114. * @param size The size of face edge in the texture.
  30115. * @param options The options defining the texture.
  30116. * @returns The texture
  30117. */
  30118. private _createDepthStencilTexture;
  30119. /**
  30120. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30121. * @param renderTarget The render target to set the frame buffer for
  30122. */
  30123. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30124. /** @hidden */
  30125. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30126. /** @hidden */
  30127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30128. /** @hidden */
  30129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30130. /** @hidden */
  30131. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30132. /** @hidden */
  30133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30134. /**
  30135. * @hidden
  30136. */
  30137. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30138. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30139. private _prepareWebGLTexture;
  30140. /** @hidden */
  30141. _releaseFramebufferObjects(texture: InternalTexture): void;
  30142. /** @hidden */
  30143. _releaseTexture(texture: InternalTexture): void;
  30144. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30145. protected _setProgram(program: WebGLProgram): void;
  30146. protected _boundUniforms: {
  30147. [key: number]: WebGLUniformLocation;
  30148. };
  30149. /**
  30150. * Binds an effect to the webGL context
  30151. * @param effect defines the effect to bind
  30152. */
  30153. bindSamplers(effect: Effect): void;
  30154. private _activateCurrentTexture;
  30155. /** @hidden */
  30156. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30157. /** @hidden */
  30158. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30159. /**
  30160. * Unbind all textures from the webGL context
  30161. */
  30162. unbindAllTextures(): void;
  30163. /**
  30164. * Sets a texture to the according uniform.
  30165. * @param channel The texture channel
  30166. * @param uniform The uniform to set
  30167. * @param texture The texture to apply
  30168. */
  30169. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30170. private _bindSamplerUniformToChannel;
  30171. private _getTextureWrapMode;
  30172. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30173. /**
  30174. * Sets an array of texture to the webGL context
  30175. * @param channel defines the channel where the texture array must be set
  30176. * @param uniform defines the associated uniform location
  30177. * @param textures defines the array of textures to bind
  30178. */
  30179. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30180. /** @hidden */
  30181. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30182. private _setTextureParameterFloat;
  30183. private _setTextureParameterInteger;
  30184. /**
  30185. * Unbind all vertex attributes from the webGL context
  30186. */
  30187. unbindAllAttributes(): void;
  30188. /**
  30189. * 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
  30190. */
  30191. releaseEffects(): void;
  30192. /**
  30193. * Dispose and release all associated resources
  30194. */
  30195. dispose(): void;
  30196. /**
  30197. * Attach a new callback raised when context lost event is fired
  30198. * @param callback defines the callback to call
  30199. */
  30200. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30201. /**
  30202. * Attach a new callback raised when context restored event is fired
  30203. * @param callback defines the callback to call
  30204. */
  30205. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30206. /**
  30207. * Get the current error code of the webGL context
  30208. * @returns the error code
  30209. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30210. */
  30211. getError(): number;
  30212. private _canRenderToFloatFramebuffer;
  30213. private _canRenderToHalfFloatFramebuffer;
  30214. private _canRenderToFramebuffer;
  30215. /** @hidden */
  30216. _getWebGLTextureType(type: number): number;
  30217. /** @hidden */
  30218. _getInternalFormat(format: number): number;
  30219. /** @hidden */
  30220. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30221. /** @hidden */
  30222. _getRGBAMultiSampleBufferFormat(type: number): number;
  30223. /** @hidden */
  30224. _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;
  30225. /**
  30226. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30227. * @returns true if the engine can be created
  30228. * @ignorenaming
  30229. */
  30230. static isSupported(): boolean;
  30231. /**
  30232. * Find the next highest power of two.
  30233. * @param x Number to start search from.
  30234. * @return Next highest power of two.
  30235. */
  30236. static CeilingPOT(x: number): number;
  30237. /**
  30238. * Find the next lowest power of two.
  30239. * @param x Number to start search from.
  30240. * @return Next lowest power of two.
  30241. */
  30242. static FloorPOT(x: number): number;
  30243. /**
  30244. * Find the nearest power of two.
  30245. * @param x Number to start search from.
  30246. * @return Next nearest power of two.
  30247. */
  30248. static NearestPOT(x: number): number;
  30249. /**
  30250. * Get the closest exponent of two
  30251. * @param value defines the value to approximate
  30252. * @param max defines the maximum value to return
  30253. * @param mode defines how to define the closest value
  30254. * @returns closest exponent of two of the given value
  30255. */
  30256. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30257. /**
  30258. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30259. * @param func - the function to be called
  30260. * @param requester - the object that will request the next frame. Falls back to window.
  30261. * @returns frame number
  30262. */
  30263. static QueueNewFrame(func: () => void, requester?: any): number;
  30264. }
  30265. }
  30266. declare module BABYLON {
  30267. /**
  30268. * Class used to store data associated with WebGL texture data for the engine
  30269. * This class should not be used directly
  30270. */
  30271. export class InternalTexture {
  30272. /** @hidden */
  30273. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30274. /**
  30275. * The source of the texture data is unknown
  30276. */
  30277. static DATASOURCE_UNKNOWN: number;
  30278. /**
  30279. * Texture data comes from an URL
  30280. */
  30281. static DATASOURCE_URL: number;
  30282. /**
  30283. * Texture data is only used for temporary storage
  30284. */
  30285. static DATASOURCE_TEMP: number;
  30286. /**
  30287. * Texture data comes from raw data (ArrayBuffer)
  30288. */
  30289. static DATASOURCE_RAW: number;
  30290. /**
  30291. * Texture content is dynamic (video or dynamic texture)
  30292. */
  30293. static DATASOURCE_DYNAMIC: number;
  30294. /**
  30295. * Texture content is generated by rendering to it
  30296. */
  30297. static DATASOURCE_RENDERTARGET: number;
  30298. /**
  30299. * Texture content is part of a multi render target process
  30300. */
  30301. static DATASOURCE_MULTIRENDERTARGET: number;
  30302. /**
  30303. * Texture data comes from a cube data file
  30304. */
  30305. static DATASOURCE_CUBE: number;
  30306. /**
  30307. * Texture data comes from a raw cube data
  30308. */
  30309. static DATASOURCE_CUBERAW: number;
  30310. /**
  30311. * Texture data come from a prefiltered cube data file
  30312. */
  30313. static DATASOURCE_CUBEPREFILTERED: number;
  30314. /**
  30315. * Texture content is raw 3D data
  30316. */
  30317. static DATASOURCE_RAW3D: number;
  30318. /**
  30319. * Texture content is a depth texture
  30320. */
  30321. static DATASOURCE_DEPTHTEXTURE: number;
  30322. /**
  30323. * Texture data comes from a raw cube data encoded with RGBD
  30324. */
  30325. static DATASOURCE_CUBERAW_RGBD: number;
  30326. /**
  30327. * Defines if the texture is ready
  30328. */
  30329. isReady: boolean;
  30330. /**
  30331. * Defines if the texture is a cube texture
  30332. */
  30333. isCube: boolean;
  30334. /**
  30335. * Defines if the texture contains 3D data
  30336. */
  30337. is3D: boolean;
  30338. /**
  30339. * Defines if the texture contains multiview data
  30340. */
  30341. isMultiview: boolean;
  30342. /**
  30343. * Gets the URL used to load this texture
  30344. */
  30345. url: string;
  30346. /**
  30347. * Gets the sampling mode of the texture
  30348. */
  30349. samplingMode: number;
  30350. /**
  30351. * Gets a boolean indicating if the texture needs mipmaps generation
  30352. */
  30353. generateMipMaps: boolean;
  30354. /**
  30355. * Gets the number of samples used by the texture (WebGL2+ only)
  30356. */
  30357. samples: number;
  30358. /**
  30359. * Gets the type of the texture (int, float...)
  30360. */
  30361. type: number;
  30362. /**
  30363. * Gets the format of the texture (RGB, RGBA...)
  30364. */
  30365. format: number;
  30366. /**
  30367. * Observable called when the texture is loaded
  30368. */
  30369. onLoadedObservable: Observable<InternalTexture>;
  30370. /**
  30371. * Gets the width of the texture
  30372. */
  30373. width: number;
  30374. /**
  30375. * Gets the height of the texture
  30376. */
  30377. height: number;
  30378. /**
  30379. * Gets the depth of the texture
  30380. */
  30381. depth: number;
  30382. /**
  30383. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30384. */
  30385. baseWidth: number;
  30386. /**
  30387. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30388. */
  30389. baseHeight: number;
  30390. /**
  30391. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30392. */
  30393. baseDepth: number;
  30394. /**
  30395. * Gets a boolean indicating if the texture is inverted on Y axis
  30396. */
  30397. invertY: boolean;
  30398. /** @hidden */
  30399. _invertVScale: boolean;
  30400. /** @hidden */
  30401. _associatedChannel: number;
  30402. /** @hidden */
  30403. _dataSource: number;
  30404. /** @hidden */
  30405. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30406. /** @hidden */
  30407. _bufferView: Nullable<ArrayBufferView>;
  30408. /** @hidden */
  30409. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30410. /** @hidden */
  30411. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30412. /** @hidden */
  30413. _size: number;
  30414. /** @hidden */
  30415. _extension: string;
  30416. /** @hidden */
  30417. _files: Nullable<string[]>;
  30418. /** @hidden */
  30419. _workingCanvas: Nullable<HTMLCanvasElement>;
  30420. /** @hidden */
  30421. _workingContext: Nullable<CanvasRenderingContext2D>;
  30422. /** @hidden */
  30423. _framebuffer: Nullable<WebGLFramebuffer>;
  30424. /** @hidden */
  30425. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30426. /** @hidden */
  30427. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30428. /** @hidden */
  30429. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30430. /** @hidden */
  30431. _attachments: Nullable<number[]>;
  30432. /** @hidden */
  30433. _cachedCoordinatesMode: Nullable<number>;
  30434. /** @hidden */
  30435. _cachedWrapU: Nullable<number>;
  30436. /** @hidden */
  30437. _cachedWrapV: Nullable<number>;
  30438. /** @hidden */
  30439. _cachedWrapR: Nullable<number>;
  30440. /** @hidden */
  30441. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30442. /** @hidden */
  30443. _isDisabled: boolean;
  30444. /** @hidden */
  30445. _compression: Nullable<string>;
  30446. /** @hidden */
  30447. _generateStencilBuffer: boolean;
  30448. /** @hidden */
  30449. _generateDepthBuffer: boolean;
  30450. /** @hidden */
  30451. _comparisonFunction: number;
  30452. /** @hidden */
  30453. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30454. /** @hidden */
  30455. _lodGenerationScale: number;
  30456. /** @hidden */
  30457. _lodGenerationOffset: number;
  30458. /** @hidden */
  30459. _colorTextureArray: Nullable<WebGLTexture>;
  30460. /** @hidden */
  30461. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30462. /** @hidden */
  30463. _lodTextureHigh: Nullable<BaseTexture>;
  30464. /** @hidden */
  30465. _lodTextureMid: Nullable<BaseTexture>;
  30466. /** @hidden */
  30467. _lodTextureLow: Nullable<BaseTexture>;
  30468. /** @hidden */
  30469. _isRGBD: boolean;
  30470. /** @hidden */
  30471. _linearSpecularLOD: boolean;
  30472. /** @hidden */
  30473. _irradianceTexture: Nullable<BaseTexture>;
  30474. /** @hidden */
  30475. _webGLTexture: Nullable<WebGLTexture>;
  30476. /** @hidden */
  30477. _references: number;
  30478. private _engine;
  30479. /**
  30480. * Gets the Engine the texture belongs to.
  30481. * @returns The babylon engine
  30482. */
  30483. getEngine(): ThinEngine;
  30484. /**
  30485. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  30486. */
  30487. readonly dataSource: number;
  30488. /**
  30489. * Creates a new InternalTexture
  30490. * @param engine defines the engine to use
  30491. * @param dataSource defines the type of data that will be used
  30492. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30493. */
  30494. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  30495. /**
  30496. * Increments the number of references (ie. the number of Texture that point to it)
  30497. */
  30498. incrementReferences(): void;
  30499. /**
  30500. * Change the size of the texture (not the size of the content)
  30501. * @param width defines the new width
  30502. * @param height defines the new height
  30503. * @param depth defines the new depth (1 by default)
  30504. */
  30505. updateSize(width: int, height: int, depth?: int): void;
  30506. /** @hidden */
  30507. _rebuild(): void;
  30508. /** @hidden */
  30509. _swapAndDie(target: InternalTexture): void;
  30510. /**
  30511. * Dispose the current allocated resources
  30512. */
  30513. dispose(): void;
  30514. }
  30515. }
  30516. declare module BABYLON {
  30517. /**
  30518. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30520. */
  30521. export class Analyser {
  30522. /**
  30523. * Gets or sets the smoothing
  30524. * @ignorenaming
  30525. */
  30526. SMOOTHING: number;
  30527. /**
  30528. * Gets or sets the FFT table size
  30529. * @ignorenaming
  30530. */
  30531. FFT_SIZE: number;
  30532. /**
  30533. * Gets or sets the bar graph amplitude
  30534. * @ignorenaming
  30535. */
  30536. BARGRAPHAMPLITUDE: number;
  30537. /**
  30538. * Gets or sets the position of the debug canvas
  30539. * @ignorenaming
  30540. */
  30541. DEBUGCANVASPOS: {
  30542. x: number;
  30543. y: number;
  30544. };
  30545. /**
  30546. * Gets or sets the debug canvas size
  30547. * @ignorenaming
  30548. */
  30549. DEBUGCANVASSIZE: {
  30550. width: number;
  30551. height: number;
  30552. };
  30553. private _byteFreqs;
  30554. private _byteTime;
  30555. private _floatFreqs;
  30556. private _webAudioAnalyser;
  30557. private _debugCanvas;
  30558. private _debugCanvasContext;
  30559. private _scene;
  30560. private _registerFunc;
  30561. private _audioEngine;
  30562. /**
  30563. * Creates a new analyser
  30564. * @param scene defines hosting scene
  30565. */
  30566. constructor(scene: Scene);
  30567. /**
  30568. * Get the number of data values you will have to play with for the visualization
  30569. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30570. * @returns a number
  30571. */
  30572. getFrequencyBinCount(): number;
  30573. /**
  30574. * Gets the current frequency data as a byte array
  30575. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30576. * @returns a Uint8Array
  30577. */
  30578. getByteFrequencyData(): Uint8Array;
  30579. /**
  30580. * Gets the current waveform as a byte array
  30581. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30582. * @returns a Uint8Array
  30583. */
  30584. getByteTimeDomainData(): Uint8Array;
  30585. /**
  30586. * Gets the current frequency data as a float array
  30587. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30588. * @returns a Float32Array
  30589. */
  30590. getFloatFrequencyData(): Float32Array;
  30591. /**
  30592. * Renders the debug canvas
  30593. */
  30594. drawDebugCanvas(): void;
  30595. /**
  30596. * Stops rendering the debug canvas and removes it
  30597. */
  30598. stopDebugCanvas(): void;
  30599. /**
  30600. * Connects two audio nodes
  30601. * @param inputAudioNode defines first node to connect
  30602. * @param outputAudioNode defines second node to connect
  30603. */
  30604. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30605. /**
  30606. * Releases all associated resources
  30607. */
  30608. dispose(): void;
  30609. }
  30610. }
  30611. declare module BABYLON {
  30612. /**
  30613. * This represents an audio engine and it is responsible
  30614. * to play, synchronize and analyse sounds throughout the application.
  30615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30616. */
  30617. export interface IAudioEngine extends IDisposable {
  30618. /**
  30619. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30620. */
  30621. readonly canUseWebAudio: boolean;
  30622. /**
  30623. * Gets the current AudioContext if available.
  30624. */
  30625. readonly audioContext: Nullable<AudioContext>;
  30626. /**
  30627. * The master gain node defines the global audio volume of your audio engine.
  30628. */
  30629. readonly masterGain: GainNode;
  30630. /**
  30631. * Gets whether or not mp3 are supported by your browser.
  30632. */
  30633. readonly isMP3supported: boolean;
  30634. /**
  30635. * Gets whether or not ogg are supported by your browser.
  30636. */
  30637. readonly isOGGsupported: boolean;
  30638. /**
  30639. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30640. * @ignoreNaming
  30641. */
  30642. WarnedWebAudioUnsupported: boolean;
  30643. /**
  30644. * Defines if the audio engine relies on a custom unlocked button.
  30645. * In this case, the embedded button will not be displayed.
  30646. */
  30647. useCustomUnlockedButton: boolean;
  30648. /**
  30649. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30650. */
  30651. readonly unlocked: boolean;
  30652. /**
  30653. * Event raised when audio has been unlocked on the browser.
  30654. */
  30655. onAudioUnlockedObservable: Observable<AudioEngine>;
  30656. /**
  30657. * Event raised when audio has been locked on the browser.
  30658. */
  30659. onAudioLockedObservable: Observable<AudioEngine>;
  30660. /**
  30661. * Flags the audio engine in Locked state.
  30662. * This happens due to new browser policies preventing audio to autoplay.
  30663. */
  30664. lock(): void;
  30665. /**
  30666. * Unlocks the audio engine once a user action has been done on the dom.
  30667. * This is helpful to resume play once browser policies have been satisfied.
  30668. */
  30669. unlock(): void;
  30670. }
  30671. /**
  30672. * This represents the default audio engine used in babylon.
  30673. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30675. */
  30676. export class AudioEngine implements IAudioEngine {
  30677. private _audioContext;
  30678. private _audioContextInitialized;
  30679. private _muteButton;
  30680. private _hostElement;
  30681. /**
  30682. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30683. */
  30684. canUseWebAudio: boolean;
  30685. /**
  30686. * The master gain node defines the global audio volume of your audio engine.
  30687. */
  30688. masterGain: GainNode;
  30689. /**
  30690. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30691. * @ignoreNaming
  30692. */
  30693. WarnedWebAudioUnsupported: boolean;
  30694. /**
  30695. * Gets whether or not mp3 are supported by your browser.
  30696. */
  30697. isMP3supported: boolean;
  30698. /**
  30699. * Gets whether or not ogg are supported by your browser.
  30700. */
  30701. isOGGsupported: boolean;
  30702. /**
  30703. * Gets whether audio has been unlocked on the device.
  30704. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30705. * a user interaction has happened.
  30706. */
  30707. unlocked: boolean;
  30708. /**
  30709. * Defines if the audio engine relies on a custom unlocked button.
  30710. * In this case, the embedded button will not be displayed.
  30711. */
  30712. useCustomUnlockedButton: boolean;
  30713. /**
  30714. * Event raised when audio has been unlocked on the browser.
  30715. */
  30716. onAudioUnlockedObservable: Observable<AudioEngine>;
  30717. /**
  30718. * Event raised when audio has been locked on the browser.
  30719. */
  30720. onAudioLockedObservable: Observable<AudioEngine>;
  30721. /**
  30722. * Gets the current AudioContext if available.
  30723. */
  30724. readonly audioContext: Nullable<AudioContext>;
  30725. private _connectedAnalyser;
  30726. /**
  30727. * Instantiates a new audio engine.
  30728. *
  30729. * There should be only one per page as some browsers restrict the number
  30730. * of audio contexts you can create.
  30731. * @param hostElement defines the host element where to display the mute icon if necessary
  30732. */
  30733. constructor(hostElement?: Nullable<HTMLElement>);
  30734. /**
  30735. * Flags the audio engine in Locked state.
  30736. * This happens due to new browser policies preventing audio to autoplay.
  30737. */
  30738. lock(): void;
  30739. /**
  30740. * Unlocks the audio engine once a user action has been done on the dom.
  30741. * This is helpful to resume play once browser policies have been satisfied.
  30742. */
  30743. unlock(): void;
  30744. private _resumeAudioContext;
  30745. private _initializeAudioContext;
  30746. private _tryToRun;
  30747. private _triggerRunningState;
  30748. private _triggerSuspendedState;
  30749. private _displayMuteButton;
  30750. private _moveButtonToTopLeft;
  30751. private _onResize;
  30752. private _hideMuteButton;
  30753. /**
  30754. * Destroy and release the resources associated with the audio ccontext.
  30755. */
  30756. dispose(): void;
  30757. /**
  30758. * Gets the global volume sets on the master gain.
  30759. * @returns the global volume if set or -1 otherwise
  30760. */
  30761. getGlobalVolume(): number;
  30762. /**
  30763. * Sets the global volume of your experience (sets on the master gain).
  30764. * @param newVolume Defines the new global volume of the application
  30765. */
  30766. setGlobalVolume(newVolume: number): void;
  30767. /**
  30768. * Connect the audio engine to an audio analyser allowing some amazing
  30769. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30771. * @param analyser The analyser to connect to the engine
  30772. */
  30773. connectToAnalyser(analyser: Analyser): void;
  30774. }
  30775. }
  30776. declare module BABYLON {
  30777. /**
  30778. * Interface used to present a loading screen while loading a scene
  30779. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30780. */
  30781. export interface ILoadingScreen {
  30782. /**
  30783. * Function called to display the loading screen
  30784. */
  30785. displayLoadingUI: () => void;
  30786. /**
  30787. * Function called to hide the loading screen
  30788. */
  30789. hideLoadingUI: () => void;
  30790. /**
  30791. * Gets or sets the color to use for the background
  30792. */
  30793. loadingUIBackgroundColor: string;
  30794. /**
  30795. * Gets or sets the text to display while loading
  30796. */
  30797. loadingUIText: string;
  30798. }
  30799. /**
  30800. * Class used for the default loading screen
  30801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30802. */
  30803. export class DefaultLoadingScreen implements ILoadingScreen {
  30804. private _renderingCanvas;
  30805. private _loadingText;
  30806. private _loadingDivBackgroundColor;
  30807. private _loadingDiv;
  30808. private _loadingTextDiv;
  30809. /** Gets or sets the logo url to use for the default loading screen */
  30810. static DefaultLogoUrl: string;
  30811. /** Gets or sets the spinner url to use for the default loading screen */
  30812. static DefaultSpinnerUrl: string;
  30813. /**
  30814. * Creates a new default loading screen
  30815. * @param _renderingCanvas defines the canvas used to render the scene
  30816. * @param _loadingText defines the default text to display
  30817. * @param _loadingDivBackgroundColor defines the default background color
  30818. */
  30819. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30820. /**
  30821. * Function called to display the loading screen
  30822. */
  30823. displayLoadingUI(): void;
  30824. /**
  30825. * Function called to hide the loading screen
  30826. */
  30827. hideLoadingUI(): void;
  30828. /**
  30829. * Gets or sets the text to display while loading
  30830. */
  30831. loadingUIText: string;
  30832. /**
  30833. * Gets or sets the color to use for the background
  30834. */
  30835. loadingUIBackgroundColor: string;
  30836. private _resizeLoadingUI;
  30837. }
  30838. }
  30839. declare module BABYLON {
  30840. /**
  30841. * Interface for any object that can request an animation frame
  30842. */
  30843. export interface ICustomAnimationFrameRequester {
  30844. /**
  30845. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30846. */
  30847. renderFunction?: Function;
  30848. /**
  30849. * Called to request the next frame to render to
  30850. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30851. */
  30852. requestAnimationFrame: Function;
  30853. /**
  30854. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30855. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30856. */
  30857. requestID?: number;
  30858. }
  30859. }
  30860. declare module BABYLON {
  30861. /**
  30862. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30863. */
  30864. export class PerformanceMonitor {
  30865. private _enabled;
  30866. private _rollingFrameTime;
  30867. private _lastFrameTimeMs;
  30868. /**
  30869. * constructor
  30870. * @param frameSampleSize The number of samples required to saturate the sliding window
  30871. */
  30872. constructor(frameSampleSize?: number);
  30873. /**
  30874. * Samples current frame
  30875. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30876. */
  30877. sampleFrame(timeMs?: number): void;
  30878. /**
  30879. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30880. */
  30881. readonly averageFrameTime: number;
  30882. /**
  30883. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30884. */
  30885. readonly averageFrameTimeVariance: number;
  30886. /**
  30887. * Returns the frame time of the most recent frame
  30888. */
  30889. readonly instantaneousFrameTime: number;
  30890. /**
  30891. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30892. */
  30893. readonly averageFPS: number;
  30894. /**
  30895. * Returns the average framerate in frames per second using the most recent frame time
  30896. */
  30897. readonly instantaneousFPS: number;
  30898. /**
  30899. * Returns true if enough samples have been taken to completely fill the sliding window
  30900. */
  30901. readonly isSaturated: boolean;
  30902. /**
  30903. * Enables contributions to the sliding window sample set
  30904. */
  30905. enable(): void;
  30906. /**
  30907. * Disables contributions to the sliding window sample set
  30908. * Samples will not be interpolated over the disabled period
  30909. */
  30910. disable(): void;
  30911. /**
  30912. * Returns true if sampling is enabled
  30913. */
  30914. readonly isEnabled: boolean;
  30915. /**
  30916. * Resets performance monitor
  30917. */
  30918. reset(): void;
  30919. }
  30920. /**
  30921. * RollingAverage
  30922. *
  30923. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30924. */
  30925. export class RollingAverage {
  30926. /**
  30927. * Current average
  30928. */
  30929. average: number;
  30930. /**
  30931. * Current variance
  30932. */
  30933. variance: number;
  30934. protected _samples: Array<number>;
  30935. protected _sampleCount: number;
  30936. protected _pos: number;
  30937. protected _m2: number;
  30938. /**
  30939. * constructor
  30940. * @param length The number of samples required to saturate the sliding window
  30941. */
  30942. constructor(length: number);
  30943. /**
  30944. * Adds a sample to the sample set
  30945. * @param v The sample value
  30946. */
  30947. add(v: number): void;
  30948. /**
  30949. * Returns previously added values or null if outside of history or outside the sliding window domain
  30950. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30951. * @return Value previously recorded with add() or null if outside of range
  30952. */
  30953. history(i: number): number;
  30954. /**
  30955. * Returns true if enough samples have been taken to completely fill the sliding window
  30956. * @return true if sample-set saturated
  30957. */
  30958. isSaturated(): boolean;
  30959. /**
  30960. * Resets the rolling average (equivalent to 0 samples taken so far)
  30961. */
  30962. reset(): void;
  30963. /**
  30964. * Wraps a value around the sample range boundaries
  30965. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30966. * @return Wrapped position in sample range
  30967. */
  30968. protected _wrapPosition(i: number): number;
  30969. }
  30970. }
  30971. declare module BABYLON {
  30972. /**
  30973. * Defines the interface used by display changed events
  30974. */
  30975. export interface IDisplayChangedEventArgs {
  30976. /** Gets the vrDisplay object (if any) */
  30977. vrDisplay: Nullable<any>;
  30978. /** Gets a boolean indicating if webVR is supported */
  30979. vrSupported: boolean;
  30980. }
  30981. /**
  30982. * Defines the interface used by objects containing a viewport (like a camera)
  30983. */
  30984. interface IViewportOwnerLike {
  30985. /**
  30986. * Gets or sets the viewport
  30987. */
  30988. viewport: IViewportLike;
  30989. }
  30990. /**
  30991. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30992. */
  30993. export class Engine extends ThinEngine {
  30994. /** Defines that alpha blending is disabled */
  30995. static readonly ALPHA_DISABLE: number;
  30996. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30997. static readonly ALPHA_ADD: number;
  30998. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30999. static readonly ALPHA_COMBINE: number;
  31000. /** Defines that alpha blending to DEST - SRC * DEST */
  31001. static readonly ALPHA_SUBTRACT: number;
  31002. /** Defines that alpha blending to SRC * DEST */
  31003. static readonly ALPHA_MULTIPLY: number;
  31004. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31005. static readonly ALPHA_MAXIMIZED: number;
  31006. /** Defines that alpha blending to SRC + DEST */
  31007. static readonly ALPHA_ONEONE: number;
  31008. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31009. static readonly ALPHA_PREMULTIPLIED: number;
  31010. /**
  31011. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31012. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31013. */
  31014. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31015. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31016. static readonly ALPHA_INTERPOLATE: number;
  31017. /**
  31018. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31019. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31020. */
  31021. static readonly ALPHA_SCREENMODE: number;
  31022. /** Defines that the ressource is not delayed*/
  31023. static readonly DELAYLOADSTATE_NONE: number;
  31024. /** Defines that the ressource was successfully delay loaded */
  31025. static readonly DELAYLOADSTATE_LOADED: number;
  31026. /** Defines that the ressource is currently delay loading */
  31027. static readonly DELAYLOADSTATE_LOADING: number;
  31028. /** Defines that the ressource is delayed and has not started loading */
  31029. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31031. static readonly NEVER: number;
  31032. /** 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 */
  31033. static readonly ALWAYS: number;
  31034. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31035. static readonly LESS: number;
  31036. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31037. static readonly EQUAL: number;
  31038. /** 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 */
  31039. static readonly LEQUAL: number;
  31040. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31041. static readonly GREATER: number;
  31042. /** 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 */
  31043. static readonly GEQUAL: number;
  31044. /** 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 */
  31045. static readonly NOTEQUAL: number;
  31046. /** Passed to stencilOperation to specify that stencil value must be kept */
  31047. static readonly KEEP: number;
  31048. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31049. static readonly REPLACE: number;
  31050. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31051. static readonly INCR: number;
  31052. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31053. static readonly DECR: number;
  31054. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31055. static readonly INVERT: number;
  31056. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31057. static readonly INCR_WRAP: number;
  31058. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31059. static readonly DECR_WRAP: number;
  31060. /** Texture is not repeating outside of 0..1 UVs */
  31061. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31062. /** Texture is repeating outside of 0..1 UVs */
  31063. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31064. /** Texture is repeating and mirrored */
  31065. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31066. /** ALPHA */
  31067. static readonly TEXTUREFORMAT_ALPHA: number;
  31068. /** LUMINANCE */
  31069. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31070. /** LUMINANCE_ALPHA */
  31071. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31072. /** RGB */
  31073. static readonly TEXTUREFORMAT_RGB: number;
  31074. /** RGBA */
  31075. static readonly TEXTUREFORMAT_RGBA: number;
  31076. /** RED */
  31077. static readonly TEXTUREFORMAT_RED: number;
  31078. /** RED (2nd reference) */
  31079. static readonly TEXTUREFORMAT_R: number;
  31080. /** RG */
  31081. static readonly TEXTUREFORMAT_RG: number;
  31082. /** RED_INTEGER */
  31083. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31084. /** RED_INTEGER (2nd reference) */
  31085. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31086. /** RG_INTEGER */
  31087. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31088. /** RGB_INTEGER */
  31089. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31090. /** RGBA_INTEGER */
  31091. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31092. /** UNSIGNED_BYTE */
  31093. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31094. /** UNSIGNED_BYTE (2nd reference) */
  31095. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31096. /** FLOAT */
  31097. static readonly TEXTURETYPE_FLOAT: number;
  31098. /** HALF_FLOAT */
  31099. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31100. /** BYTE */
  31101. static readonly TEXTURETYPE_BYTE: number;
  31102. /** SHORT */
  31103. static readonly TEXTURETYPE_SHORT: number;
  31104. /** UNSIGNED_SHORT */
  31105. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31106. /** INT */
  31107. static readonly TEXTURETYPE_INT: number;
  31108. /** UNSIGNED_INT */
  31109. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31110. /** UNSIGNED_SHORT_4_4_4_4 */
  31111. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31112. /** UNSIGNED_SHORT_5_5_5_1 */
  31113. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31114. /** UNSIGNED_SHORT_5_6_5 */
  31115. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31116. /** UNSIGNED_INT_2_10_10_10_REV */
  31117. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31118. /** UNSIGNED_INT_24_8 */
  31119. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31120. /** UNSIGNED_INT_10F_11F_11F_REV */
  31121. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31122. /** UNSIGNED_INT_5_9_9_9_REV */
  31123. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31124. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31125. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31126. /** nearest is mag = nearest and min = nearest and mip = linear */
  31127. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31128. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31129. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31130. /** Trilinear is mag = linear and min = linear and mip = linear */
  31131. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31132. /** nearest is mag = nearest and min = nearest and mip = linear */
  31133. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31134. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31135. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31136. /** Trilinear is mag = linear and min = linear and mip = linear */
  31137. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31138. /** mag = nearest and min = nearest and mip = nearest */
  31139. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31140. /** mag = nearest and min = linear and mip = nearest */
  31141. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31142. /** mag = nearest and min = linear and mip = linear */
  31143. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31144. /** mag = nearest and min = linear and mip = none */
  31145. static readonly TEXTURE_NEAREST_LINEAR: number;
  31146. /** mag = nearest and min = nearest and mip = none */
  31147. static readonly TEXTURE_NEAREST_NEAREST: number;
  31148. /** mag = linear and min = nearest and mip = nearest */
  31149. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31150. /** mag = linear and min = nearest and mip = linear */
  31151. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31152. /** mag = linear and min = linear and mip = none */
  31153. static readonly TEXTURE_LINEAR_LINEAR: number;
  31154. /** mag = linear and min = nearest and mip = none */
  31155. static readonly TEXTURE_LINEAR_NEAREST: number;
  31156. /** Explicit coordinates mode */
  31157. static readonly TEXTURE_EXPLICIT_MODE: number;
  31158. /** Spherical coordinates mode */
  31159. static readonly TEXTURE_SPHERICAL_MODE: number;
  31160. /** Planar coordinates mode */
  31161. static readonly TEXTURE_PLANAR_MODE: number;
  31162. /** Cubic coordinates mode */
  31163. static readonly TEXTURE_CUBIC_MODE: number;
  31164. /** Projection coordinates mode */
  31165. static readonly TEXTURE_PROJECTION_MODE: number;
  31166. /** Skybox coordinates mode */
  31167. static readonly TEXTURE_SKYBOX_MODE: number;
  31168. /** Inverse Cubic coordinates mode */
  31169. static readonly TEXTURE_INVCUBIC_MODE: number;
  31170. /** Equirectangular coordinates mode */
  31171. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31172. /** Equirectangular Fixed coordinates mode */
  31173. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31174. /** Equirectangular Fixed Mirrored coordinates mode */
  31175. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31176. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31177. static readonly SCALEMODE_FLOOR: number;
  31178. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31179. static readonly SCALEMODE_NEAREST: number;
  31180. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31181. static readonly SCALEMODE_CEILING: number;
  31182. /**
  31183. * Returns the current npm package of the sdk
  31184. */
  31185. static readonly NpmPackage: string;
  31186. /**
  31187. * Returns the current version of the framework
  31188. */
  31189. static readonly Version: string;
  31190. /** Gets the list of created engines */
  31191. static readonly Instances: Engine[];
  31192. /**
  31193. * Gets the latest created engine
  31194. */
  31195. static readonly LastCreatedEngine: Nullable<Engine>;
  31196. /**
  31197. * Gets the latest created scene
  31198. */
  31199. static readonly LastCreatedScene: Nullable<Scene>;
  31200. /**
  31201. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31202. * @param flag defines which part of the materials must be marked as dirty
  31203. * @param predicate defines a predicate used to filter which materials should be affected
  31204. */
  31205. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31206. /**
  31207. * Method called to create the default loading screen.
  31208. * This can be overriden in your own app.
  31209. * @param canvas The rendering canvas element
  31210. * @returns The loading screen
  31211. */
  31212. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31213. /**
  31214. * Method called to create the default rescale post process on each engine.
  31215. */
  31216. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31217. /**
  31218. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31219. **/
  31220. enableOfflineSupport: boolean;
  31221. /**
  31222. * 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)
  31223. **/
  31224. disableManifestCheck: boolean;
  31225. /**
  31226. * Gets the list of created scenes
  31227. */
  31228. scenes: Scene[];
  31229. /**
  31230. * Event raised when a new scene is created
  31231. */
  31232. onNewSceneAddedObservable: Observable<Scene>;
  31233. /**
  31234. * Gets the list of created postprocesses
  31235. */
  31236. postProcesses: PostProcess[];
  31237. /**
  31238. * Observable event triggered each time the rendering canvas is resized
  31239. */
  31240. onResizeObservable: Observable<Engine>;
  31241. /**
  31242. * Observable event triggered each time the canvas loses focus
  31243. */
  31244. onCanvasBlurObservable: Observable<Engine>;
  31245. /**
  31246. * Observable event triggered each time the canvas gains focus
  31247. */
  31248. onCanvasFocusObservable: Observable<Engine>;
  31249. /**
  31250. * Observable event triggered each time the canvas receives pointerout event
  31251. */
  31252. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31253. /**
  31254. * Observable event triggered before each texture is initialized
  31255. */
  31256. onBeforeTextureInitObservable: Observable<Texture>;
  31257. /**
  31258. * Observable raised when the engine begins a new frame
  31259. */
  31260. onBeginFrameObservable: Observable<Engine>;
  31261. /**
  31262. * If set, will be used to request the next animation frame for the render loop
  31263. */
  31264. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31265. /**
  31266. * Observable raised when the engine ends the current frame
  31267. */
  31268. onEndFrameObservable: Observable<Engine>;
  31269. /**
  31270. * Observable raised when the engine is about to compile a shader
  31271. */
  31272. onBeforeShaderCompilationObservable: Observable<Engine>;
  31273. /**
  31274. * Observable raised when the engine has jsut compiled a shader
  31275. */
  31276. onAfterShaderCompilationObservable: Observable<Engine>;
  31277. /**
  31278. * Gets the audio engine
  31279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31280. * @ignorenaming
  31281. */
  31282. static audioEngine: IAudioEngine;
  31283. /**
  31284. * Default AudioEngine factory responsible of creating the Audio Engine.
  31285. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31286. */
  31287. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31288. /**
  31289. * Default offline support factory responsible of creating a tool used to store data locally.
  31290. * By default, this will create a Database object if the workload has been embedded.
  31291. */
  31292. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31293. private _loadingScreen;
  31294. private _pointerLockRequested;
  31295. private _dummyFramebuffer;
  31296. private _rescalePostProcess;
  31297. /** @hidden */
  31298. protected _alphaMode: number;
  31299. /** @hidden */
  31300. protected _alphaEquation: number;
  31301. private _deterministicLockstep;
  31302. private _lockstepMaxSteps;
  31303. protected readonly _supportsHardwareTextureRescaling: boolean;
  31304. private _fps;
  31305. private _deltaTime;
  31306. /**
  31307. * Turn this value on if you want to pause FPS computation when in background
  31308. */
  31309. disablePerformanceMonitorInBackground: boolean;
  31310. private _performanceMonitor;
  31311. /**
  31312. * Gets the performance monitor attached to this engine
  31313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31314. */
  31315. readonly performanceMonitor: PerformanceMonitor;
  31316. private _onFocus;
  31317. private _onBlur;
  31318. private _onCanvasPointerOut;
  31319. private _onCanvasBlur;
  31320. private _onCanvasFocus;
  31321. private _onFullscreenChange;
  31322. private _onPointerLockChange;
  31323. /**
  31324. * Creates a new engine
  31325. * @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
  31326. * @param antialias defines enable antialiasing (default: false)
  31327. * @param options defines further options to be sent to the getContext() function
  31328. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31329. */
  31330. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31331. /**
  31332. * Gets current aspect ratio
  31333. * @param viewportOwner defines the camera to use to get the aspect ratio
  31334. * @param useScreen defines if screen size must be used (or the current render target if any)
  31335. * @returns a number defining the aspect ratio
  31336. */
  31337. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31338. /**
  31339. * Gets current screen aspect ratio
  31340. * @returns a number defining the aspect ratio
  31341. */
  31342. getScreenAspectRatio(): number;
  31343. /**
  31344. * Gets host document
  31345. * @returns the host document object
  31346. */
  31347. getHostDocument(): Document;
  31348. /**
  31349. * Gets the client rect of the HTML canvas attached with the current webGL context
  31350. * @returns a client rectanglee
  31351. */
  31352. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31353. /**
  31354. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31355. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31356. * @returns true if engine is in deterministic lock step mode
  31357. */
  31358. isDeterministicLockStep(): boolean;
  31359. /**
  31360. * Gets the max steps when engine is running in deterministic lock step
  31361. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31362. * @returns the max steps
  31363. */
  31364. getLockstepMaxSteps(): number;
  31365. /**
  31366. * Force the mipmap generation for the given render target texture
  31367. * @param texture defines the render target texture to use
  31368. */
  31369. generateMipMapsForCubemap(texture: InternalTexture): void;
  31370. /** States */
  31371. /**
  31372. * Set various states to the webGL context
  31373. * @param culling defines backface culling state
  31374. * @param zOffset defines the value to apply to zOffset (0 by default)
  31375. * @param force defines if states must be applied even if cache is up to date
  31376. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31377. */
  31378. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31379. /**
  31380. * Set the z offset to apply to current rendering
  31381. * @param value defines the offset to apply
  31382. */
  31383. setZOffset(value: number): void;
  31384. /**
  31385. * Gets the current value of the zOffset
  31386. * @returns the current zOffset state
  31387. */
  31388. getZOffset(): number;
  31389. /**
  31390. * Enable or disable depth buffering
  31391. * @param enable defines the state to set
  31392. */
  31393. setDepthBuffer(enable: boolean): void;
  31394. /**
  31395. * Gets a boolean indicating if depth writing is enabled
  31396. * @returns the current depth writing state
  31397. */
  31398. getDepthWrite(): boolean;
  31399. /**
  31400. * Enable or disable depth writing
  31401. * @param enable defines the state to set
  31402. */
  31403. setDepthWrite(enable: boolean): void;
  31404. /**
  31405. * Enable or disable color writing
  31406. * @param enable defines the state to set
  31407. */
  31408. setColorWrite(enable: boolean): void;
  31409. /**
  31410. * Gets a boolean indicating if color writing is enabled
  31411. * @returns the current color writing state
  31412. */
  31413. getColorWrite(): boolean;
  31414. /**
  31415. * Sets alpha constants used by some alpha blending modes
  31416. * @param r defines the red component
  31417. * @param g defines the green component
  31418. * @param b defines the blue component
  31419. * @param a defines the alpha component
  31420. */
  31421. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31422. /**
  31423. * Sets the current alpha mode
  31424. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31425. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31427. */
  31428. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31429. /**
  31430. * Gets the current alpha mode
  31431. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31432. * @returns the current alpha mode
  31433. */
  31434. getAlphaMode(): number;
  31435. /**
  31436. * Sets the current alpha equation
  31437. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31438. */
  31439. setAlphaEquation(equation: number): void;
  31440. /**
  31441. * Gets the current alpha equation.
  31442. * @returns the current alpha equation
  31443. */
  31444. getAlphaEquation(): number;
  31445. /**
  31446. * Gets a boolean indicating if stencil buffer is enabled
  31447. * @returns the current stencil buffer state
  31448. */
  31449. getStencilBuffer(): boolean;
  31450. /**
  31451. * Enable or disable the stencil buffer
  31452. * @param enable defines if the stencil buffer must be enabled or disabled
  31453. */
  31454. setStencilBuffer(enable: boolean): void;
  31455. /**
  31456. * Gets the current stencil mask
  31457. * @returns a number defining the new stencil mask to use
  31458. */
  31459. getStencilMask(): number;
  31460. /**
  31461. * Sets the current stencil mask
  31462. * @param mask defines the new stencil mask to use
  31463. */
  31464. setStencilMask(mask: number): void;
  31465. /**
  31466. * Gets the current stencil function
  31467. * @returns a number defining the stencil function to use
  31468. */
  31469. getStencilFunction(): number;
  31470. /**
  31471. * Gets the current stencil reference value
  31472. * @returns a number defining the stencil reference value to use
  31473. */
  31474. getStencilFunctionReference(): number;
  31475. /**
  31476. * Gets the current stencil mask
  31477. * @returns a number defining the stencil mask to use
  31478. */
  31479. getStencilFunctionMask(): number;
  31480. /**
  31481. * Sets the current stencil function
  31482. * @param stencilFunc defines the new stencil function to use
  31483. */
  31484. setStencilFunction(stencilFunc: number): void;
  31485. /**
  31486. * Sets the current stencil reference
  31487. * @param reference defines the new stencil reference to use
  31488. */
  31489. setStencilFunctionReference(reference: number): void;
  31490. /**
  31491. * Sets the current stencil mask
  31492. * @param mask defines the new stencil mask to use
  31493. */
  31494. setStencilFunctionMask(mask: number): void;
  31495. /**
  31496. * Gets the current stencil operation when stencil fails
  31497. * @returns a number defining stencil operation to use when stencil fails
  31498. */
  31499. getStencilOperationFail(): number;
  31500. /**
  31501. * Gets the current stencil operation when depth fails
  31502. * @returns a number defining stencil operation to use when depth fails
  31503. */
  31504. getStencilOperationDepthFail(): number;
  31505. /**
  31506. * Gets the current stencil operation when stencil passes
  31507. * @returns a number defining stencil operation to use when stencil passes
  31508. */
  31509. getStencilOperationPass(): number;
  31510. /**
  31511. * Sets the stencil operation to use when stencil fails
  31512. * @param operation defines the stencil operation to use when stencil fails
  31513. */
  31514. setStencilOperationFail(operation: number): void;
  31515. /**
  31516. * Sets the stencil operation to use when depth fails
  31517. * @param operation defines the stencil operation to use when depth fails
  31518. */
  31519. setStencilOperationDepthFail(operation: number): void;
  31520. /**
  31521. * Sets the stencil operation to use when stencil passes
  31522. * @param operation defines the stencil operation to use when stencil passes
  31523. */
  31524. setStencilOperationPass(operation: number): void;
  31525. /**
  31526. * Sets a boolean indicating if the dithering state is enabled or disabled
  31527. * @param value defines the dithering state
  31528. */
  31529. setDitheringState(value: boolean): void;
  31530. /**
  31531. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31532. * @param value defines the rasterizer state
  31533. */
  31534. setRasterizerState(value: boolean): void;
  31535. /**
  31536. * Gets the current depth function
  31537. * @returns a number defining the depth function
  31538. */
  31539. getDepthFunction(): Nullable<number>;
  31540. /**
  31541. * Sets the current depth function
  31542. * @param depthFunc defines the function to use
  31543. */
  31544. setDepthFunction(depthFunc: number): void;
  31545. /**
  31546. * Sets the current depth function to GREATER
  31547. */
  31548. setDepthFunctionToGreater(): void;
  31549. /**
  31550. * Sets the current depth function to GEQUAL
  31551. */
  31552. setDepthFunctionToGreaterOrEqual(): void;
  31553. /**
  31554. * Sets the current depth function to LESS
  31555. */
  31556. setDepthFunctionToLess(): void;
  31557. /**
  31558. * Sets the current depth function to LEQUAL
  31559. */
  31560. setDepthFunctionToLessOrEqual(): void;
  31561. private _cachedStencilBuffer;
  31562. private _cachedStencilFunction;
  31563. private _cachedStencilMask;
  31564. private _cachedStencilOperationPass;
  31565. private _cachedStencilOperationFail;
  31566. private _cachedStencilOperationDepthFail;
  31567. private _cachedStencilReference;
  31568. /**
  31569. * Caches the the state of the stencil buffer
  31570. */
  31571. cacheStencilState(): void;
  31572. /**
  31573. * Restores the state of the stencil buffer
  31574. */
  31575. restoreStencilState(): void;
  31576. /**
  31577. * Directly set the WebGL Viewport
  31578. * @param x defines the x coordinate of the viewport (in screen space)
  31579. * @param y defines the y coordinate of the viewport (in screen space)
  31580. * @param width defines the width of the viewport (in screen space)
  31581. * @param height defines the height of the viewport (in screen space)
  31582. * @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
  31583. */
  31584. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31585. /**
  31586. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31587. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31588. * @param y defines the y-coordinate of the corner of the clear rectangle
  31589. * @param width defines the width of the clear rectangle
  31590. * @param height defines the height of the clear rectangle
  31591. * @param clearColor defines the clear color
  31592. */
  31593. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31594. /**
  31595. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31596. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31597. * @param y defines the y-coordinate of the corner of the clear rectangle
  31598. * @param width defines the width of the clear rectangle
  31599. * @param height defines the height of the clear rectangle
  31600. */
  31601. enableScissor(x: number, y: number, width: number, height: number): void;
  31602. /**
  31603. * Disable previously set scissor test rectangle
  31604. */
  31605. disableScissor(): void;
  31606. /**
  31607. * Initializes a webVR display and starts listening to display change events
  31608. * The onVRDisplayChangedObservable will be notified upon these changes
  31609. * @returns The onVRDisplayChangedObservable
  31610. */
  31611. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31612. /** @hidden */
  31613. _prepareVRComponent(): void;
  31614. /** @hidden */
  31615. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31616. /** @hidden */
  31617. _submitVRFrame(): void;
  31618. /**
  31619. * Call this function to leave webVR mode
  31620. * Will do nothing if webVR is not supported or if there is no webVR device
  31621. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31622. */
  31623. disableVR(): void;
  31624. /**
  31625. * Gets a boolean indicating that the system is in VR mode and is presenting
  31626. * @returns true if VR mode is engaged
  31627. */
  31628. isVRPresenting(): boolean;
  31629. /** @hidden */
  31630. _requestVRFrame(): void;
  31631. /** @hidden */
  31632. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31633. /**
  31634. * Gets the source code of the vertex shader associated with a specific webGL program
  31635. * @param program defines the program to use
  31636. * @returns a string containing the source code of the vertex shader associated with the program
  31637. */
  31638. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31639. /**
  31640. * Gets the source code of the fragment shader associated with a specific webGL program
  31641. * @param program defines the program to use
  31642. * @returns a string containing the source code of the fragment shader associated with the program
  31643. */
  31644. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31645. /**
  31646. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31647. * @param x defines the x coordinate of the rectangle where pixels must be read
  31648. * @param y defines the y coordinate of the rectangle where pixels must be read
  31649. * @param width defines the width of the rectangle where pixels must be read
  31650. * @param height defines the height of the rectangle where pixels must be read
  31651. * @returns a Uint8Array containing RGBA colors
  31652. */
  31653. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31654. /**
  31655. * Sets a depth stencil texture from a render target to the according uniform.
  31656. * @param channel The texture channel
  31657. * @param uniform The uniform to set
  31658. * @param texture The render target texture containing the depth stencil texture to apply
  31659. */
  31660. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31661. /**
  31662. * Sets a texture to the webGL context from a postprocess
  31663. * @param channel defines the channel to use
  31664. * @param postProcess defines the source postprocess
  31665. */
  31666. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31667. /**
  31668. * Binds the output of the passed in post process to the texture channel specified
  31669. * @param channel The channel the texture should be bound to
  31670. * @param postProcess The post process which's output should be bound
  31671. */
  31672. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31673. /** @hidden */
  31674. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31675. protected _rebuildBuffers(): void;
  31676. _renderLoop(): void;
  31677. /**
  31678. * Toggle full screen mode
  31679. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31680. */
  31681. switchFullscreen(requestPointerLock: boolean): void;
  31682. /**
  31683. * Enters full screen mode
  31684. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31685. */
  31686. enterFullscreen(requestPointerLock: boolean): void;
  31687. /**
  31688. * Exits full screen mode
  31689. */
  31690. exitFullscreen(): void;
  31691. /**
  31692. * Enters Pointerlock mode
  31693. */
  31694. enterPointerlock(): void;
  31695. /**
  31696. * Exits Pointerlock mode
  31697. */
  31698. exitPointerlock(): void;
  31699. /**
  31700. * Begin a new frame
  31701. */
  31702. beginFrame(): void;
  31703. /**
  31704. * Enf the current frame
  31705. */
  31706. endFrame(): void;
  31707. resize(): void;
  31708. /**
  31709. * Force a specific size of the canvas
  31710. * @param width defines the new canvas' width
  31711. * @param height defines the new canvas' height
  31712. */
  31713. setSize(width: number, height: number): void;
  31714. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31715. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31716. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31717. _releaseTexture(texture: InternalTexture): void;
  31718. /**
  31719. * @hidden
  31720. * Rescales a texture
  31721. * @param source input texutre
  31722. * @param destination destination texture
  31723. * @param scene scene to use to render the resize
  31724. * @param internalFormat format to use when resizing
  31725. * @param onComplete callback to be called when resize has completed
  31726. */
  31727. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31728. /**
  31729. * Gets the current framerate
  31730. * @returns a number representing the framerate
  31731. */
  31732. getFps(): number;
  31733. /**
  31734. * Gets the time spent between current and previous frame
  31735. * @returns a number representing the delta time in ms
  31736. */
  31737. getDeltaTime(): number;
  31738. private _measureFps;
  31739. /**
  31740. * Creates a new render target texture
  31741. * @param size defines the size of the texture
  31742. * @param options defines the options used to create the texture
  31743. * @returns a new render target texture stored in an InternalTexture
  31744. */
  31745. createRenderTargetTexture(size: number | {
  31746. width: number;
  31747. height: number;
  31748. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31749. /**
  31750. * Updates the sample count of a render target texture
  31751. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31752. * @param texture defines the texture to update
  31753. * @param samples defines the sample count to set
  31754. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31755. */
  31756. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31757. /** @hidden */
  31758. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31759. dispose(): void;
  31760. private _disableTouchAction;
  31761. /**
  31762. * Display the loading screen
  31763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31764. */
  31765. displayLoadingUI(): void;
  31766. /**
  31767. * Hide the loading screen
  31768. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31769. */
  31770. hideLoadingUI(): void;
  31771. /**
  31772. * Gets the current loading screen object
  31773. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31774. */
  31775. /**
  31776. * Sets the current loading screen object
  31777. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31778. */
  31779. loadingScreen: ILoadingScreen;
  31780. /**
  31781. * Sets the current loading screen text
  31782. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31783. */
  31784. loadingUIText: string;
  31785. /**
  31786. * Sets the current loading screen background color
  31787. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31788. */
  31789. loadingUIBackgroundColor: string;
  31790. /** Pointerlock and fullscreen */
  31791. /**
  31792. * Ask the browser to promote the current element to pointerlock mode
  31793. * @param element defines the DOM element to promote
  31794. */
  31795. static _RequestPointerlock(element: HTMLElement): void;
  31796. /**
  31797. * Asks the browser to exit pointerlock mode
  31798. */
  31799. static _ExitPointerlock(): void;
  31800. /**
  31801. * Ask the browser to promote the current element to fullscreen rendering mode
  31802. * @param element defines the DOM element to promote
  31803. */
  31804. static _RequestFullscreen(element: HTMLElement): void;
  31805. /**
  31806. * Asks the browser to exit fullscreen mode
  31807. */
  31808. static _ExitFullscreen(): void;
  31809. }
  31810. }
  31811. declare module BABYLON {
  31812. /**
  31813. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31814. * during the life time of the application.
  31815. */
  31816. export class EngineStore {
  31817. /** Gets the list of created engines */
  31818. static Instances: Engine[];
  31819. /** @hidden */
  31820. static _LastCreatedScene: Nullable<Scene>;
  31821. /**
  31822. * Gets the latest created engine
  31823. */
  31824. static readonly LastCreatedEngine: Nullable<Engine>;
  31825. /**
  31826. * Gets the latest created scene
  31827. */
  31828. static readonly LastCreatedScene: Nullable<Scene>;
  31829. /**
  31830. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31831. * @ignorenaming
  31832. */
  31833. static UseFallbackTexture: boolean;
  31834. /**
  31835. * Texture content used if a texture cannot loaded
  31836. * @ignorenaming
  31837. */
  31838. static FallbackTexture: string;
  31839. }
  31840. }
  31841. declare module BABYLON {
  31842. /**
  31843. * Helper class that provides a small promise polyfill
  31844. */
  31845. export class PromisePolyfill {
  31846. /**
  31847. * Static function used to check if the polyfill is required
  31848. * If this is the case then the function will inject the polyfill to window.Promise
  31849. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31850. */
  31851. static Apply(force?: boolean): void;
  31852. }
  31853. }
  31854. declare module BABYLON {
  31855. /**
  31856. * Interface for screenshot methods with describe argument called `size` as object with options
  31857. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31858. */
  31859. export interface IScreenshotSize {
  31860. /**
  31861. * number in pixels for canvas height
  31862. */
  31863. height?: number;
  31864. /**
  31865. * multiplier allowing render at a higher or lower resolution
  31866. * If value is defined then height and width will be ignored and taken from camera
  31867. */
  31868. precision?: number;
  31869. /**
  31870. * number in pixels for canvas width
  31871. */
  31872. width?: number;
  31873. }
  31874. }
  31875. declare module BABYLON {
  31876. interface IColor4Like {
  31877. r: float;
  31878. g: float;
  31879. b: float;
  31880. a: float;
  31881. }
  31882. /**
  31883. * Class containing a set of static utilities functions
  31884. */
  31885. export class Tools {
  31886. /**
  31887. * Gets or sets the base URL to use to load assets
  31888. */
  31889. static BaseUrl: string;
  31890. /**
  31891. * Enable/Disable Custom HTTP Request Headers globally.
  31892. * default = false
  31893. * @see CustomRequestHeaders
  31894. */
  31895. static UseCustomRequestHeaders: boolean;
  31896. /**
  31897. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31898. * i.e. when loading files, where the server/service expects an Authorization header
  31899. */
  31900. static CustomRequestHeaders: {
  31901. [key: string]: string;
  31902. };
  31903. /**
  31904. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31905. */
  31906. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31907. /**
  31908. * Default behaviour for cors in the application.
  31909. * It can be a string if the expected behavior is identical in the entire app.
  31910. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31911. */
  31912. static CorsBehavior: string | ((url: string | string[]) => string);
  31913. /**
  31914. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31915. * @ignorenaming
  31916. */
  31917. static UseFallbackTexture: boolean;
  31918. /**
  31919. * Use this object to register external classes like custom textures or material
  31920. * to allow the laoders to instantiate them
  31921. */
  31922. static RegisteredExternalClasses: {
  31923. [key: string]: Object;
  31924. };
  31925. /**
  31926. * Texture content used if a texture cannot loaded
  31927. * @ignorenaming
  31928. */
  31929. static fallbackTexture: string;
  31930. /**
  31931. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31932. * @param u defines the coordinate on X axis
  31933. * @param v defines the coordinate on Y axis
  31934. * @param width defines the width of the source data
  31935. * @param height defines the height of the source data
  31936. * @param pixels defines the source byte array
  31937. * @param color defines the output color
  31938. */
  31939. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31940. /**
  31941. * Interpolates between a and b via alpha
  31942. * @param a The lower value (returned when alpha = 0)
  31943. * @param b The upper value (returned when alpha = 1)
  31944. * @param alpha The interpolation-factor
  31945. * @return The mixed value
  31946. */
  31947. static Mix(a: number, b: number, alpha: number): number;
  31948. /**
  31949. * Tries to instantiate a new object from a given class name
  31950. * @param className defines the class name to instantiate
  31951. * @returns the new object or null if the system was not able to do the instantiation
  31952. */
  31953. static Instantiate(className: string): any;
  31954. /**
  31955. * Provides a slice function that will work even on IE
  31956. * @param data defines the array to slice
  31957. * @param start defines the start of the data (optional)
  31958. * @param end defines the end of the data (optional)
  31959. * @returns the new sliced array
  31960. */
  31961. static Slice<T>(data: T, start?: number, end?: number): T;
  31962. /**
  31963. * Polyfill for setImmediate
  31964. * @param action defines the action to execute after the current execution block
  31965. */
  31966. static SetImmediate(action: () => void): void;
  31967. /**
  31968. * Function indicating if a number is an exponent of 2
  31969. * @param value defines the value to test
  31970. * @returns true if the value is an exponent of 2
  31971. */
  31972. static IsExponentOfTwo(value: number): boolean;
  31973. private static _tmpFloatArray;
  31974. /**
  31975. * Returns the nearest 32-bit single precision float representation of a Number
  31976. * @param value A Number. If the parameter is of a different type, it will get converted
  31977. * to a number or to NaN if it cannot be converted
  31978. * @returns number
  31979. */
  31980. static FloatRound(value: number): number;
  31981. /**
  31982. * Extracts the filename from a path
  31983. * @param path defines the path to use
  31984. * @returns the filename
  31985. */
  31986. static GetFilename(path: string): string;
  31987. /**
  31988. * Extracts the "folder" part of a path (everything before the filename).
  31989. * @param uri The URI to extract the info from
  31990. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31991. * @returns The "folder" part of the path
  31992. */
  31993. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31994. /**
  31995. * Extracts text content from a DOM element hierarchy
  31996. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31997. */
  31998. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31999. /**
  32000. * Convert an angle in radians to degrees
  32001. * @param angle defines the angle to convert
  32002. * @returns the angle in degrees
  32003. */
  32004. static ToDegrees(angle: number): number;
  32005. /**
  32006. * Convert an angle in degrees to radians
  32007. * @param angle defines the angle to convert
  32008. * @returns the angle in radians
  32009. */
  32010. static ToRadians(angle: number): number;
  32011. /**
  32012. * Encode a buffer to a base64 string
  32013. * @param buffer defines the buffer to encode
  32014. * @returns the encoded string
  32015. */
  32016. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32017. /**
  32018. * Returns an array if obj is not an array
  32019. * @param obj defines the object to evaluate as an array
  32020. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32021. * @returns either obj directly if obj is an array or a new array containing obj
  32022. */
  32023. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32024. /**
  32025. * Gets the pointer prefix to use
  32026. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32027. */
  32028. static GetPointerPrefix(): string;
  32029. /**
  32030. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32031. * @param url define the url we are trying
  32032. * @param element define the dom element where to configure the cors policy
  32033. */
  32034. static SetCorsBehavior(url: string | string[], element: {
  32035. crossOrigin: string | null;
  32036. }): void;
  32037. /**
  32038. * Removes unwanted characters from an url
  32039. * @param url defines the url to clean
  32040. * @returns the cleaned url
  32041. */
  32042. static CleanUrl(url: string): string;
  32043. /**
  32044. * Gets or sets a function used to pre-process url before using them to load assets
  32045. */
  32046. static PreprocessUrl: (url: string) => string;
  32047. /**
  32048. * Loads an image as an HTMLImageElement.
  32049. * @param input url string, ArrayBuffer, or Blob to load
  32050. * @param onLoad callback called when the image successfully loads
  32051. * @param onError callback called when the image fails to load
  32052. * @param offlineProvider offline provider for caching
  32053. * @returns the HTMLImageElement of the loaded image
  32054. */
  32055. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32056. /**
  32057. * Loads a file
  32058. * @param url url string, ArrayBuffer, or Blob to load
  32059. * @param onSuccess callback called when the file successfully loads
  32060. * @param onProgress callback called while file is loading (if the server supports this mode)
  32061. * @param offlineProvider defines the offline provider for caching
  32062. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32063. * @param onError callback called when the file fails to load
  32064. * @returns a file request object
  32065. */
  32066. 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;
  32067. /**
  32068. * Loads a file from a url
  32069. * @param url the file url to load
  32070. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32071. */
  32072. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32073. /**
  32074. * Load a script (identified by an url). When the url returns, the
  32075. * content of this file is added into a new script element, attached to the DOM (body element)
  32076. * @param scriptUrl defines the url of the script to laod
  32077. * @param onSuccess defines the callback called when the script is loaded
  32078. * @param onError defines the callback to call if an error occurs
  32079. * @param scriptId defines the id of the script element
  32080. */
  32081. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32082. /**
  32083. * Load an asynchronous script (identified by an url). When the url returns, the
  32084. * content of this file is added into a new script element, attached to the DOM (body element)
  32085. * @param scriptUrl defines the url of the script to laod
  32086. * @param scriptId defines the id of the script element
  32087. * @returns a promise request object
  32088. */
  32089. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32090. /**
  32091. * Loads a file from a blob
  32092. * @param fileToLoad defines the blob to use
  32093. * @param callback defines the callback to call when data is loaded
  32094. * @param progressCallback defines the callback to call during loading process
  32095. * @returns a file request object
  32096. */
  32097. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32098. /**
  32099. * Loads a file
  32100. * @param fileToLoad defines the file to load
  32101. * @param callback defines the callback to call when data is loaded
  32102. * @param progressCallBack defines the callback to call during loading process
  32103. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32104. * @returns a file request object
  32105. */
  32106. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32107. /**
  32108. * Creates a data url from a given string content
  32109. * @param content defines the content to convert
  32110. * @returns the new data url link
  32111. */
  32112. static FileAsURL(content: string): string;
  32113. /**
  32114. * Format the given number to a specific decimal format
  32115. * @param value defines the number to format
  32116. * @param decimals defines the number of decimals to use
  32117. * @returns the formatted string
  32118. */
  32119. static Format(value: number, decimals?: number): string;
  32120. /**
  32121. * Tries to copy an object by duplicating every property
  32122. * @param source defines the source object
  32123. * @param destination defines the target object
  32124. * @param doNotCopyList defines a list of properties to avoid
  32125. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32126. */
  32127. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32128. /**
  32129. * Gets a boolean indicating if the given object has no own property
  32130. * @param obj defines the object to test
  32131. * @returns true if object has no own property
  32132. */
  32133. static IsEmpty(obj: any): boolean;
  32134. /**
  32135. * Function used to register events at window level
  32136. * @param windowElement defines the Window object to use
  32137. * @param events defines the events to register
  32138. */
  32139. static RegisterTopRootEvents(windowElement: Window, events: {
  32140. name: string;
  32141. handler: Nullable<(e: FocusEvent) => any>;
  32142. }[]): void;
  32143. /**
  32144. * Function used to unregister events from window level
  32145. * @param windowElement defines the Window object to use
  32146. * @param events defines the events to unregister
  32147. */
  32148. static UnregisterTopRootEvents(windowElement: Window, events: {
  32149. name: string;
  32150. handler: Nullable<(e: FocusEvent) => any>;
  32151. }[]): void;
  32152. /**
  32153. * @ignore
  32154. */
  32155. static _ScreenshotCanvas: HTMLCanvasElement;
  32156. /**
  32157. * Dumps the current bound framebuffer
  32158. * @param width defines the rendering width
  32159. * @param height defines the rendering height
  32160. * @param engine defines the hosting engine
  32161. * @param successCallback defines the callback triggered once the data are available
  32162. * @param mimeType defines the mime type of the result
  32163. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32164. */
  32165. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32166. /**
  32167. * Converts the canvas data to blob.
  32168. * This acts as a polyfill for browsers not supporting the to blob function.
  32169. * @param canvas Defines the canvas to extract the data from
  32170. * @param successCallback Defines the callback triggered once the data are available
  32171. * @param mimeType Defines the mime type of the result
  32172. */
  32173. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32174. /**
  32175. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32176. * @param successCallback defines the callback triggered once the data are available
  32177. * @param mimeType defines the mime type of the result
  32178. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32179. */
  32180. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32181. /**
  32182. * Downloads a blob in the browser
  32183. * @param blob defines the blob to download
  32184. * @param fileName defines the name of the downloaded file
  32185. */
  32186. static Download(blob: Blob, fileName: string): void;
  32187. /**
  32188. * Captures a screenshot of the current rendering
  32189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32190. * @param engine defines the rendering engine
  32191. * @param camera defines the source camera
  32192. * @param size This parameter can be set to a single number or to an object with the
  32193. * following (optional) properties: precision, width, height. If a single number is passed,
  32194. * it will be used for both width and height. If an object is passed, the screenshot size
  32195. * will be derived from the parameters. The precision property is a multiplier allowing
  32196. * rendering at a higher or lower resolution
  32197. * @param successCallback defines the callback receives a single parameter which contains the
  32198. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32199. * src parameter of an <img> to display it
  32200. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32201. * Check your browser for supported MIME types
  32202. */
  32203. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32204. /**
  32205. * Captures a screenshot of the current rendering
  32206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32207. * @param engine defines the rendering engine
  32208. * @param camera defines the source camera
  32209. * @param size This parameter can be set to a single number or to an object with the
  32210. * following (optional) properties: precision, width, height. If a single number is passed,
  32211. * it will be used for both width and height. If an object is passed, the screenshot size
  32212. * will be derived from the parameters. The precision property is a multiplier allowing
  32213. * rendering at a higher or lower resolution
  32214. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32215. * Check your browser for supported MIME types
  32216. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32217. * to the src parameter of an <img> to display it
  32218. */
  32219. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32220. /**
  32221. * Generates an image screenshot from the specified camera.
  32222. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32223. * @param engine The engine to use for rendering
  32224. * @param camera The camera to use for rendering
  32225. * @param size This parameter can be set to a single number or to an object with the
  32226. * following (optional) properties: precision, width, height. If a single number is passed,
  32227. * it will be used for both width and height. If an object is passed, the screenshot size
  32228. * will be derived from the parameters. The precision property is a multiplier allowing
  32229. * rendering at a higher or lower resolution
  32230. * @param successCallback The callback receives a single parameter which contains the
  32231. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32232. * src parameter of an <img> to display it
  32233. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32234. * Check your browser for supported MIME types
  32235. * @param samples Texture samples (default: 1)
  32236. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32237. * @param fileName A name for for the downloaded file.
  32238. */
  32239. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32240. /**
  32241. * Generates an image screenshot from the specified camera.
  32242. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32243. * @param engine The engine to use for rendering
  32244. * @param camera The camera to use for rendering
  32245. * @param size This parameter can be set to a single number or to an object with the
  32246. * following (optional) properties: precision, width, height. If a single number is passed,
  32247. * it will be used for both width and height. If an object is passed, the screenshot size
  32248. * will be derived from the parameters. The precision property is a multiplier allowing
  32249. * rendering at a higher or lower resolution
  32250. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32251. * Check your browser for supported MIME types
  32252. * @param samples Texture samples (default: 1)
  32253. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32254. * @param fileName A name for for the downloaded file.
  32255. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32256. * to the src parameter of an <img> to display it
  32257. */
  32258. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32259. /**
  32260. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32261. * Be aware Math.random() could cause collisions, but:
  32262. * "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"
  32263. * @returns a pseudo random id
  32264. */
  32265. static RandomId(): string;
  32266. /**
  32267. * Test if the given uri is a base64 string
  32268. * @param uri The uri to test
  32269. * @return True if the uri is a base64 string or false otherwise
  32270. */
  32271. static IsBase64(uri: string): boolean;
  32272. /**
  32273. * Decode the given base64 uri.
  32274. * @param uri The uri to decode
  32275. * @return The decoded base64 data.
  32276. */
  32277. static DecodeBase64(uri: string): ArrayBuffer;
  32278. /**
  32279. * Gets the absolute url.
  32280. * @param url the input url
  32281. * @return the absolute url
  32282. */
  32283. static GetAbsoluteUrl(url: string): string;
  32284. /**
  32285. * No log
  32286. */
  32287. static readonly NoneLogLevel: number;
  32288. /**
  32289. * Only message logs
  32290. */
  32291. static readonly MessageLogLevel: number;
  32292. /**
  32293. * Only warning logs
  32294. */
  32295. static readonly WarningLogLevel: number;
  32296. /**
  32297. * Only error logs
  32298. */
  32299. static readonly ErrorLogLevel: number;
  32300. /**
  32301. * All logs
  32302. */
  32303. static readonly AllLogLevel: number;
  32304. /**
  32305. * Gets a value indicating the number of loading errors
  32306. * @ignorenaming
  32307. */
  32308. static readonly errorsCount: number;
  32309. /**
  32310. * Callback called when a new log is added
  32311. */
  32312. static OnNewCacheEntry: (entry: string) => void;
  32313. /**
  32314. * Log a message to the console
  32315. * @param message defines the message to log
  32316. */
  32317. static Log(message: string): void;
  32318. /**
  32319. * Write a warning message to the console
  32320. * @param message defines the message to log
  32321. */
  32322. static Warn(message: string): void;
  32323. /**
  32324. * Write an error message to the console
  32325. * @param message defines the message to log
  32326. */
  32327. static Error(message: string): void;
  32328. /**
  32329. * Gets current log cache (list of logs)
  32330. */
  32331. static readonly LogCache: string;
  32332. /**
  32333. * Clears the log cache
  32334. */
  32335. static ClearLogCache(): void;
  32336. /**
  32337. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32338. */
  32339. static LogLevels: number;
  32340. /**
  32341. * Checks if the window object exists
  32342. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32343. */
  32344. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32345. /**
  32346. * No performance log
  32347. */
  32348. static readonly PerformanceNoneLogLevel: number;
  32349. /**
  32350. * Use user marks to log performance
  32351. */
  32352. static readonly PerformanceUserMarkLogLevel: number;
  32353. /**
  32354. * Log performance to the console
  32355. */
  32356. static readonly PerformanceConsoleLogLevel: number;
  32357. private static _performance;
  32358. /**
  32359. * Sets the current performance log level
  32360. */
  32361. static PerformanceLogLevel: number;
  32362. private static _StartPerformanceCounterDisabled;
  32363. private static _EndPerformanceCounterDisabled;
  32364. private static _StartUserMark;
  32365. private static _EndUserMark;
  32366. private static _StartPerformanceConsole;
  32367. private static _EndPerformanceConsole;
  32368. /**
  32369. * Starts a performance counter
  32370. */
  32371. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32372. /**
  32373. * Ends a specific performance coutner
  32374. */
  32375. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32376. /**
  32377. * Gets either window.performance.now() if supported or Date.now() else
  32378. */
  32379. static readonly Now: number;
  32380. /**
  32381. * This method will return the name of the class used to create the instance of the given object.
  32382. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32383. * @param object the object to get the class name from
  32384. * @param isType defines if the object is actually a type
  32385. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32386. */
  32387. static GetClassName(object: any, isType?: boolean): string;
  32388. /**
  32389. * Gets the first element of an array satisfying a given predicate
  32390. * @param array defines the array to browse
  32391. * @param predicate defines the predicate to use
  32392. * @returns null if not found or the element
  32393. */
  32394. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32395. /**
  32396. * This method will return the name of the full name of the class, including its owning module (if any).
  32397. * 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).
  32398. * @param object the object to get the class name from
  32399. * @param isType defines if the object is actually a type
  32400. * @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.
  32401. * @ignorenaming
  32402. */
  32403. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32404. /**
  32405. * Returns a promise that resolves after the given amount of time.
  32406. * @param delay Number of milliseconds to delay
  32407. * @returns Promise that resolves after the given amount of time
  32408. */
  32409. static DelayAsync(delay: number): Promise<void>;
  32410. }
  32411. /**
  32412. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32413. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32414. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32415. * @param name The name of the class, case should be preserved
  32416. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32417. */
  32418. export function className(name: string, module?: string): (target: Object) => void;
  32419. /**
  32420. * An implementation of a loop for asynchronous functions.
  32421. */
  32422. export class AsyncLoop {
  32423. /**
  32424. * Defines the number of iterations for the loop
  32425. */
  32426. iterations: number;
  32427. /**
  32428. * Defines the current index of the loop.
  32429. */
  32430. index: number;
  32431. private _done;
  32432. private _fn;
  32433. private _successCallback;
  32434. /**
  32435. * Constructor.
  32436. * @param iterations the number of iterations.
  32437. * @param func the function to run each iteration
  32438. * @param successCallback the callback that will be called upon succesful execution
  32439. * @param offset starting offset.
  32440. */
  32441. constructor(
  32442. /**
  32443. * Defines the number of iterations for the loop
  32444. */
  32445. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32446. /**
  32447. * Execute the next iteration. Must be called after the last iteration was finished.
  32448. */
  32449. executeNext(): void;
  32450. /**
  32451. * Break the loop and run the success callback.
  32452. */
  32453. breakLoop(): void;
  32454. /**
  32455. * Create and run an async loop.
  32456. * @param iterations the number of iterations.
  32457. * @param fn the function to run each iteration
  32458. * @param successCallback the callback that will be called upon succesful execution
  32459. * @param offset starting offset.
  32460. * @returns the created async loop object
  32461. */
  32462. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32463. /**
  32464. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32465. * @param iterations total number of iterations
  32466. * @param syncedIterations number of synchronous iterations in each async iteration.
  32467. * @param fn the function to call each iteration.
  32468. * @param callback a success call back that will be called when iterating stops.
  32469. * @param breakFunction a break condition (optional)
  32470. * @param timeout timeout settings for the setTimeout function. default - 0.
  32471. * @returns the created async loop object
  32472. */
  32473. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32474. }
  32475. }
  32476. declare module BABYLON {
  32477. /**
  32478. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32479. * The underlying implementation relies on an associative array to ensure the best performances.
  32480. * The value can be anything including 'null' but except 'undefined'
  32481. */
  32482. export class StringDictionary<T> {
  32483. /**
  32484. * This will clear this dictionary and copy the content from the 'source' one.
  32485. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32486. * @param source the dictionary to take the content from and copy to this dictionary
  32487. */
  32488. copyFrom(source: StringDictionary<T>): void;
  32489. /**
  32490. * Get a value based from its key
  32491. * @param key the given key to get the matching value from
  32492. * @return the value if found, otherwise undefined is returned
  32493. */
  32494. get(key: string): T | undefined;
  32495. /**
  32496. * Get a value from its key or add it if it doesn't exist.
  32497. * This method will ensure you that a given key/data will be present in the dictionary.
  32498. * @param key the given key to get the matching value from
  32499. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32500. * The factory will only be invoked if there's no data for the given key.
  32501. * @return the value corresponding to the key.
  32502. */
  32503. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32504. /**
  32505. * Get a value from its key if present in the dictionary otherwise add it
  32506. * @param key the key to get the value from
  32507. * @param val if there's no such key/value pair in the dictionary add it with this value
  32508. * @return the value corresponding to the key
  32509. */
  32510. getOrAdd(key: string, val: T): T;
  32511. /**
  32512. * Check if there's a given key in the dictionary
  32513. * @param key the key to check for
  32514. * @return true if the key is present, false otherwise
  32515. */
  32516. contains(key: string): boolean;
  32517. /**
  32518. * Add a new key and its corresponding value
  32519. * @param key the key to add
  32520. * @param value the value corresponding to the key
  32521. * @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
  32522. */
  32523. add(key: string, value: T): boolean;
  32524. /**
  32525. * Update a specific value associated to a key
  32526. * @param key defines the key to use
  32527. * @param value defines the value to store
  32528. * @returns true if the value was updated (or false if the key was not found)
  32529. */
  32530. set(key: string, value: T): boolean;
  32531. /**
  32532. * Get the element of the given key and remove it from the dictionary
  32533. * @param key defines the key to search
  32534. * @returns the value associated with the key or null if not found
  32535. */
  32536. getAndRemove(key: string): Nullable<T>;
  32537. /**
  32538. * Remove a key/value from the dictionary.
  32539. * @param key the key to remove
  32540. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32541. */
  32542. remove(key: string): boolean;
  32543. /**
  32544. * Clear the whole content of the dictionary
  32545. */
  32546. clear(): void;
  32547. /**
  32548. * Gets the current count
  32549. */
  32550. readonly count: number;
  32551. /**
  32552. * Execute a callback on each key/val of the dictionary.
  32553. * Note that you can remove any element in this dictionary in the callback implementation
  32554. * @param callback the callback to execute on a given key/value pair
  32555. */
  32556. forEach(callback: (key: string, val: T) => void): void;
  32557. /**
  32558. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32559. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32560. * Note that you can remove any element in this dictionary in the callback implementation
  32561. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32562. * @returns the first item
  32563. */
  32564. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32565. private _count;
  32566. private _data;
  32567. }
  32568. }
  32569. declare module BABYLON {
  32570. /** @hidden */
  32571. export interface ICollisionCoordinator {
  32572. createCollider(): Collider;
  32573. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32574. init(scene: Scene): void;
  32575. }
  32576. /** @hidden */
  32577. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32578. private _scene;
  32579. private _scaledPosition;
  32580. private _scaledVelocity;
  32581. private _finalPosition;
  32582. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32583. createCollider(): Collider;
  32584. init(scene: Scene): void;
  32585. private _collideWithWorld;
  32586. }
  32587. }
  32588. declare module BABYLON {
  32589. /**
  32590. * Class used to manage all inputs for the scene.
  32591. */
  32592. export class InputManager {
  32593. /** The distance in pixel that you have to move to prevent some events */
  32594. static DragMovementThreshold: number;
  32595. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32596. static LongPressDelay: number;
  32597. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32598. static DoubleClickDelay: number;
  32599. /** If you need to check double click without raising a single click at first click, enable this flag */
  32600. static ExclusiveDoubleClickMode: boolean;
  32601. private _wheelEventName;
  32602. private _onPointerMove;
  32603. private _onPointerDown;
  32604. private _onPointerUp;
  32605. private _initClickEvent;
  32606. private _initActionManager;
  32607. private _delayedSimpleClick;
  32608. private _delayedSimpleClickTimeout;
  32609. private _previousDelayedSimpleClickTimeout;
  32610. private _meshPickProceed;
  32611. private _previousButtonPressed;
  32612. private _currentPickResult;
  32613. private _previousPickResult;
  32614. private _totalPointersPressed;
  32615. private _doubleClickOccured;
  32616. private _pointerOverMesh;
  32617. private _pickedDownMesh;
  32618. private _pickedUpMesh;
  32619. private _pointerX;
  32620. private _pointerY;
  32621. private _unTranslatedPointerX;
  32622. private _unTranslatedPointerY;
  32623. private _startingPointerPosition;
  32624. private _previousStartingPointerPosition;
  32625. private _startingPointerTime;
  32626. private _previousStartingPointerTime;
  32627. private _pointerCaptures;
  32628. private _onKeyDown;
  32629. private _onKeyUp;
  32630. private _onCanvasFocusObserver;
  32631. private _onCanvasBlurObserver;
  32632. private _scene;
  32633. /**
  32634. * Creates a new InputManager
  32635. * @param scene defines the hosting scene
  32636. */
  32637. constructor(scene: Scene);
  32638. /**
  32639. * Gets the mesh that is currently under the pointer
  32640. */
  32641. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32642. /**
  32643. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32644. */
  32645. readonly unTranslatedPointer: Vector2;
  32646. /**
  32647. * Gets or sets the current on-screen X position of the pointer
  32648. */
  32649. pointerX: number;
  32650. /**
  32651. * Gets or sets the current on-screen Y position of the pointer
  32652. */
  32653. pointerY: number;
  32654. private _updatePointerPosition;
  32655. private _processPointerMove;
  32656. private _setRayOnPointerInfo;
  32657. private _checkPrePointerObservable;
  32658. /**
  32659. * Use this method to simulate a pointer move on a mesh
  32660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32663. */
  32664. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32665. /**
  32666. * Use this method to simulate a pointer down on a mesh
  32667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32670. */
  32671. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32672. private _processPointerDown;
  32673. /** @hidden */
  32674. _isPointerSwiping(): boolean;
  32675. /**
  32676. * Use this method to simulate a pointer up on a mesh
  32677. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32678. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32679. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32680. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32681. */
  32682. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32683. private _processPointerUp;
  32684. /**
  32685. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32686. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32687. * @returns true if the pointer was captured
  32688. */
  32689. isPointerCaptured(pointerId?: number): boolean;
  32690. /**
  32691. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32692. * @param attachUp defines if you want to attach events to pointerup
  32693. * @param attachDown defines if you want to attach events to pointerdown
  32694. * @param attachMove defines if you want to attach events to pointermove
  32695. */
  32696. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32697. /**
  32698. * Detaches all event handlers
  32699. */
  32700. detachControl(): void;
  32701. /**
  32702. * Force the value of meshUnderPointer
  32703. * @param mesh defines the mesh to use
  32704. */
  32705. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32706. /**
  32707. * Gets the mesh under the pointer
  32708. * @returns a Mesh or null if no mesh is under the pointer
  32709. */
  32710. getPointerOverMesh(): Nullable<AbstractMesh>;
  32711. }
  32712. }
  32713. declare module BABYLON {
  32714. /**
  32715. * Helper class used to generate session unique ID
  32716. */
  32717. export class UniqueIdGenerator {
  32718. private static _UniqueIdCounter;
  32719. /**
  32720. * Gets an unique (relatively to the current scene) Id
  32721. */
  32722. static readonly UniqueId: number;
  32723. }
  32724. }
  32725. declare module BABYLON {
  32726. /**
  32727. * This class defines the direct association between an animation and a target
  32728. */
  32729. export class TargetedAnimation {
  32730. /**
  32731. * Animation to perform
  32732. */
  32733. animation: Animation;
  32734. /**
  32735. * Target to animate
  32736. */
  32737. target: any;
  32738. /**
  32739. * Serialize the object
  32740. * @returns the JSON object representing the current entity
  32741. */
  32742. serialize(): any;
  32743. }
  32744. /**
  32745. * Use this class to create coordinated animations on multiple targets
  32746. */
  32747. export class AnimationGroup implements IDisposable {
  32748. /** The name of the animation group */
  32749. name: string;
  32750. private _scene;
  32751. private _targetedAnimations;
  32752. private _animatables;
  32753. private _from;
  32754. private _to;
  32755. private _isStarted;
  32756. private _isPaused;
  32757. private _speedRatio;
  32758. private _loopAnimation;
  32759. /**
  32760. * Gets or sets the unique id of the node
  32761. */
  32762. uniqueId: number;
  32763. /**
  32764. * This observable will notify when one animation have ended
  32765. */
  32766. onAnimationEndObservable: Observable<TargetedAnimation>;
  32767. /**
  32768. * Observer raised when one animation loops
  32769. */
  32770. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32771. /**
  32772. * This observable will notify when all animations have ended.
  32773. */
  32774. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32775. /**
  32776. * This observable will notify when all animations have paused.
  32777. */
  32778. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32779. /**
  32780. * This observable will notify when all animations are playing.
  32781. */
  32782. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32783. /**
  32784. * Gets the first frame
  32785. */
  32786. readonly from: number;
  32787. /**
  32788. * Gets the last frame
  32789. */
  32790. readonly to: number;
  32791. /**
  32792. * Define if the animations are started
  32793. */
  32794. readonly isStarted: boolean;
  32795. /**
  32796. * Gets a value indicating that the current group is playing
  32797. */
  32798. readonly isPlaying: boolean;
  32799. /**
  32800. * Gets or sets the speed ratio to use for all animations
  32801. */
  32802. /**
  32803. * Gets or sets the speed ratio to use for all animations
  32804. */
  32805. speedRatio: number;
  32806. /**
  32807. * Gets or sets if all animations should loop or not
  32808. */
  32809. loopAnimation: boolean;
  32810. /**
  32811. * Gets the targeted animations for this animation group
  32812. */
  32813. readonly targetedAnimations: Array<TargetedAnimation>;
  32814. /**
  32815. * returning the list of animatables controlled by this animation group.
  32816. */
  32817. readonly animatables: Array<Animatable>;
  32818. /**
  32819. * Instantiates a new Animation Group.
  32820. * This helps managing several animations at once.
  32821. * @see http://doc.babylonjs.com/how_to/group
  32822. * @param name Defines the name of the group
  32823. * @param scene Defines the scene the group belongs to
  32824. */
  32825. constructor(
  32826. /** The name of the animation group */
  32827. name: string, scene?: Nullable<Scene>);
  32828. /**
  32829. * Add an animation (with its target) in the group
  32830. * @param animation defines the animation we want to add
  32831. * @param target defines the target of the animation
  32832. * @returns the TargetedAnimation object
  32833. */
  32834. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32835. /**
  32836. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32837. * It can add constant keys at begin or end
  32838. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32839. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32840. * @returns the animation group
  32841. */
  32842. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32843. /**
  32844. * Start all animations on given targets
  32845. * @param loop defines if animations must loop
  32846. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32847. * @param from defines the from key (optional)
  32848. * @param to defines the to key (optional)
  32849. * @returns the current animation group
  32850. */
  32851. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32852. /**
  32853. * Pause all animations
  32854. * @returns the animation group
  32855. */
  32856. pause(): AnimationGroup;
  32857. /**
  32858. * Play all animations to initial state
  32859. * This function will start() the animations if they were not started or will restart() them if they were paused
  32860. * @param loop defines if animations must loop
  32861. * @returns the animation group
  32862. */
  32863. play(loop?: boolean): AnimationGroup;
  32864. /**
  32865. * Reset all animations to initial state
  32866. * @returns the animation group
  32867. */
  32868. reset(): AnimationGroup;
  32869. /**
  32870. * Restart animations from key 0
  32871. * @returns the animation group
  32872. */
  32873. restart(): AnimationGroup;
  32874. /**
  32875. * Stop all animations
  32876. * @returns the animation group
  32877. */
  32878. stop(): AnimationGroup;
  32879. /**
  32880. * Set animation weight for all animatables
  32881. * @param weight defines the weight to use
  32882. * @return the animationGroup
  32883. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32884. */
  32885. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32886. /**
  32887. * Synchronize and normalize all animatables with a source animatable
  32888. * @param root defines the root animatable to synchronize with
  32889. * @return the animationGroup
  32890. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32891. */
  32892. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32893. /**
  32894. * Goes to a specific frame in this animation group
  32895. * @param frame the frame number to go to
  32896. * @return the animationGroup
  32897. */
  32898. goToFrame(frame: number): AnimationGroup;
  32899. /**
  32900. * Dispose all associated resources
  32901. */
  32902. dispose(): void;
  32903. private _checkAnimationGroupEnded;
  32904. /**
  32905. * Clone the current animation group and returns a copy
  32906. * @param newName defines the name of the new group
  32907. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32908. * @returns the new aniamtion group
  32909. */
  32910. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32911. /**
  32912. * Serializes the animationGroup to an object
  32913. * @returns Serialized object
  32914. */
  32915. serialize(): any;
  32916. /**
  32917. * Returns a new AnimationGroup object parsed from the source provided.
  32918. * @param parsedAnimationGroup defines the source
  32919. * @param scene defines the scene that will receive the animationGroup
  32920. * @returns a new AnimationGroup
  32921. */
  32922. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32923. /**
  32924. * Returns the string "AnimationGroup"
  32925. * @returns "AnimationGroup"
  32926. */
  32927. getClassName(): string;
  32928. /**
  32929. * Creates a detailled string about the object
  32930. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32931. * @returns a string representing the object
  32932. */
  32933. toString(fullDetails?: boolean): string;
  32934. }
  32935. }
  32936. declare module BABYLON {
  32937. /**
  32938. * Define an interface for all classes that will hold resources
  32939. */
  32940. export interface IDisposable {
  32941. /**
  32942. * Releases all held resources
  32943. */
  32944. dispose(): void;
  32945. }
  32946. /** Interface defining initialization parameters for Scene class */
  32947. export interface SceneOptions {
  32948. /**
  32949. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32950. * It will improve performance when the number of geometries becomes important.
  32951. */
  32952. useGeometryUniqueIdsMap?: boolean;
  32953. /**
  32954. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32955. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32956. */
  32957. useMaterialMeshMap?: boolean;
  32958. /**
  32959. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32960. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32961. */
  32962. useClonedMeshhMap?: boolean;
  32963. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32964. virtual?: boolean;
  32965. }
  32966. /**
  32967. * Represents a scene to be rendered by the engine.
  32968. * @see http://doc.babylonjs.com/features/scene
  32969. */
  32970. export class Scene extends AbstractScene implements IAnimatable {
  32971. /** The fog is deactivated */
  32972. static readonly FOGMODE_NONE: number;
  32973. /** The fog density is following an exponential function */
  32974. static readonly FOGMODE_EXP: number;
  32975. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32976. static readonly FOGMODE_EXP2: number;
  32977. /** The fog density is following a linear function. */
  32978. static readonly FOGMODE_LINEAR: number;
  32979. /**
  32980. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32981. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32982. */
  32983. static MinDeltaTime: number;
  32984. /**
  32985. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32987. */
  32988. static MaxDeltaTime: number;
  32989. /**
  32990. * Factory used to create the default material.
  32991. * @param name The name of the material to create
  32992. * @param scene The scene to create the material for
  32993. * @returns The default material
  32994. */
  32995. static DefaultMaterialFactory(scene: Scene): Material;
  32996. /**
  32997. * Factory used to create the a collision coordinator.
  32998. * @returns The collision coordinator
  32999. */
  33000. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33001. /** @hidden */
  33002. _inputManager: InputManager;
  33003. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33004. cameraToUseForPointers: Nullable<Camera>;
  33005. /** @hidden */
  33006. readonly _isScene: boolean;
  33007. /**
  33008. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33009. */
  33010. autoClear: boolean;
  33011. /**
  33012. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33013. */
  33014. autoClearDepthAndStencil: boolean;
  33015. /**
  33016. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33017. */
  33018. clearColor: Color4;
  33019. /**
  33020. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33021. */
  33022. ambientColor: Color3;
  33023. /**
  33024. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33025. * It should only be one of the following (if not the default embedded one):
  33026. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33027. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33028. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33029. * The material properties need to be setup according to the type of texture in use.
  33030. */
  33031. environmentBRDFTexture: BaseTexture;
  33032. /** @hidden */
  33033. protected _environmentTexture: Nullable<BaseTexture>;
  33034. /**
  33035. * Texture used in all pbr material as the reflection texture.
  33036. * As in the majority of the scene they are the same (exception for multi room and so on),
  33037. * this is easier to reference from here than from all the materials.
  33038. */
  33039. /**
  33040. * Texture used in all pbr material as the reflection texture.
  33041. * As in the majority of the scene they are the same (exception for multi room and so on),
  33042. * this is easier to set here than in all the materials.
  33043. */
  33044. environmentTexture: Nullable<BaseTexture>;
  33045. /** @hidden */
  33046. protected _environmentIntensity: number;
  33047. /**
  33048. * Intensity of the environment in all pbr material.
  33049. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33050. * As in the majority of the scene they are the same (exception for multi room and so on),
  33051. * this is easier to reference from here than from all the materials.
  33052. */
  33053. /**
  33054. * Intensity of the environment in all pbr material.
  33055. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33056. * As in the majority of the scene they are the same (exception for multi room and so on),
  33057. * this is easier to set here than in all the materials.
  33058. */
  33059. environmentIntensity: number;
  33060. /** @hidden */
  33061. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33062. /**
  33063. * Default image processing configuration used either in the rendering
  33064. * Forward main pass or through the imageProcessingPostProcess if present.
  33065. * As in the majority of the scene they are the same (exception for multi camera),
  33066. * this is easier to reference from here than from all the materials and post process.
  33067. *
  33068. * No setter as we it is a shared configuration, you can set the values instead.
  33069. */
  33070. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33071. private _forceWireframe;
  33072. /**
  33073. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33074. */
  33075. forceWireframe: boolean;
  33076. private _forcePointsCloud;
  33077. /**
  33078. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33079. */
  33080. forcePointsCloud: boolean;
  33081. /**
  33082. * Gets or sets the active clipplane 1
  33083. */
  33084. clipPlane: Nullable<Plane>;
  33085. /**
  33086. * Gets or sets the active clipplane 2
  33087. */
  33088. clipPlane2: Nullable<Plane>;
  33089. /**
  33090. * Gets or sets the active clipplane 3
  33091. */
  33092. clipPlane3: Nullable<Plane>;
  33093. /**
  33094. * Gets or sets the active clipplane 4
  33095. */
  33096. clipPlane4: Nullable<Plane>;
  33097. /**
  33098. * Gets or sets a boolean indicating if animations are enabled
  33099. */
  33100. animationsEnabled: boolean;
  33101. private _animationPropertiesOverride;
  33102. /**
  33103. * Gets or sets the animation properties override
  33104. */
  33105. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33106. /**
  33107. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33108. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33109. */
  33110. useConstantAnimationDeltaTime: boolean;
  33111. /**
  33112. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33113. * Please note that it requires to run a ray cast through the scene on every frame
  33114. */
  33115. constantlyUpdateMeshUnderPointer: boolean;
  33116. /**
  33117. * Defines the HTML cursor to use when hovering over interactive elements
  33118. */
  33119. hoverCursor: string;
  33120. /**
  33121. * Defines the HTML default cursor to use (empty by default)
  33122. */
  33123. defaultCursor: string;
  33124. /**
  33125. * This is used to call preventDefault() on pointer down
  33126. * in order to block unwanted artifacts like system double clicks
  33127. */
  33128. preventDefaultOnPointerDown: boolean;
  33129. /**
  33130. * This is used to call preventDefault() on pointer up
  33131. * in order to block unwanted artifacts like system double clicks
  33132. */
  33133. preventDefaultOnPointerUp: boolean;
  33134. /**
  33135. * Gets or sets user defined metadata
  33136. */
  33137. metadata: any;
  33138. /**
  33139. * For internal use only. Please do not use.
  33140. */
  33141. reservedDataStore: any;
  33142. /**
  33143. * Gets the name of the plugin used to load this scene (null by default)
  33144. */
  33145. loadingPluginName: string;
  33146. /**
  33147. * Use this array to add regular expressions used to disable offline support for specific urls
  33148. */
  33149. disableOfflineSupportExceptionRules: RegExp[];
  33150. /**
  33151. * An event triggered when the scene is disposed.
  33152. */
  33153. onDisposeObservable: Observable<Scene>;
  33154. private _onDisposeObserver;
  33155. /** Sets a function to be executed when this scene is disposed. */
  33156. onDispose: () => void;
  33157. /**
  33158. * An event triggered before rendering the scene (right after animations and physics)
  33159. */
  33160. onBeforeRenderObservable: Observable<Scene>;
  33161. private _onBeforeRenderObserver;
  33162. /** Sets a function to be executed before rendering this scene */
  33163. beforeRender: Nullable<() => void>;
  33164. /**
  33165. * An event triggered after rendering the scene
  33166. */
  33167. onAfterRenderObservable: Observable<Scene>;
  33168. /**
  33169. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33170. */
  33171. onAfterRenderCameraObservable: Observable<Camera>;
  33172. private _onAfterRenderObserver;
  33173. /** Sets a function to be executed after rendering this scene */
  33174. afterRender: Nullable<() => void>;
  33175. /**
  33176. * An event triggered before animating the scene
  33177. */
  33178. onBeforeAnimationsObservable: Observable<Scene>;
  33179. /**
  33180. * An event triggered after animations processing
  33181. */
  33182. onAfterAnimationsObservable: Observable<Scene>;
  33183. /**
  33184. * An event triggered before draw calls are ready to be sent
  33185. */
  33186. onBeforeDrawPhaseObservable: Observable<Scene>;
  33187. /**
  33188. * An event triggered after draw calls have been sent
  33189. */
  33190. onAfterDrawPhaseObservable: Observable<Scene>;
  33191. /**
  33192. * An event triggered when the scene is ready
  33193. */
  33194. onReadyObservable: Observable<Scene>;
  33195. /**
  33196. * An event triggered before rendering a camera
  33197. */
  33198. onBeforeCameraRenderObservable: Observable<Camera>;
  33199. private _onBeforeCameraRenderObserver;
  33200. /** Sets a function to be executed before rendering a camera*/
  33201. beforeCameraRender: () => void;
  33202. /**
  33203. * An event triggered after rendering a camera
  33204. */
  33205. onAfterCameraRenderObservable: Observable<Camera>;
  33206. private _onAfterCameraRenderObserver;
  33207. /** Sets a function to be executed after rendering a camera*/
  33208. afterCameraRender: () => void;
  33209. /**
  33210. * An event triggered when active meshes evaluation is about to start
  33211. */
  33212. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33213. /**
  33214. * An event triggered when active meshes evaluation is done
  33215. */
  33216. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33217. /**
  33218. * An event triggered when particles rendering is about to start
  33219. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33220. */
  33221. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33222. /**
  33223. * An event triggered when particles rendering is done
  33224. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33225. */
  33226. onAfterParticlesRenderingObservable: Observable<Scene>;
  33227. /**
  33228. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33229. */
  33230. onDataLoadedObservable: Observable<Scene>;
  33231. /**
  33232. * An event triggered when a camera is created
  33233. */
  33234. onNewCameraAddedObservable: Observable<Camera>;
  33235. /**
  33236. * An event triggered when a camera is removed
  33237. */
  33238. onCameraRemovedObservable: Observable<Camera>;
  33239. /**
  33240. * An event triggered when a light is created
  33241. */
  33242. onNewLightAddedObservable: Observable<Light>;
  33243. /**
  33244. * An event triggered when a light is removed
  33245. */
  33246. onLightRemovedObservable: Observable<Light>;
  33247. /**
  33248. * An event triggered when a geometry is created
  33249. */
  33250. onNewGeometryAddedObservable: Observable<Geometry>;
  33251. /**
  33252. * An event triggered when a geometry is removed
  33253. */
  33254. onGeometryRemovedObservable: Observable<Geometry>;
  33255. /**
  33256. * An event triggered when a transform node is created
  33257. */
  33258. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33259. /**
  33260. * An event triggered when a transform node is removed
  33261. */
  33262. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33263. /**
  33264. * An event triggered when a mesh is created
  33265. */
  33266. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33267. /**
  33268. * An event triggered when a mesh is removed
  33269. */
  33270. onMeshRemovedObservable: Observable<AbstractMesh>;
  33271. /**
  33272. * An event triggered when a skeleton is created
  33273. */
  33274. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33275. /**
  33276. * An event triggered when a skeleton is removed
  33277. */
  33278. onSkeletonRemovedObservable: Observable<Skeleton>;
  33279. /**
  33280. * An event triggered when a material is created
  33281. */
  33282. onNewMaterialAddedObservable: Observable<Material>;
  33283. /**
  33284. * An event triggered when a material is removed
  33285. */
  33286. onMaterialRemovedObservable: Observable<Material>;
  33287. /**
  33288. * An event triggered when a texture is created
  33289. */
  33290. onNewTextureAddedObservable: Observable<BaseTexture>;
  33291. /**
  33292. * An event triggered when a texture is removed
  33293. */
  33294. onTextureRemovedObservable: Observable<BaseTexture>;
  33295. /**
  33296. * An event triggered when render targets are about to be rendered
  33297. * Can happen multiple times per frame.
  33298. */
  33299. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33300. /**
  33301. * An event triggered when render targets were rendered.
  33302. * Can happen multiple times per frame.
  33303. */
  33304. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33305. /**
  33306. * An event triggered before calculating deterministic simulation step
  33307. */
  33308. onBeforeStepObservable: Observable<Scene>;
  33309. /**
  33310. * An event triggered after calculating deterministic simulation step
  33311. */
  33312. onAfterStepObservable: Observable<Scene>;
  33313. /**
  33314. * An event triggered when the activeCamera property is updated
  33315. */
  33316. onActiveCameraChanged: Observable<Scene>;
  33317. /**
  33318. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33319. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33320. * 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)
  33321. */
  33322. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33323. /**
  33324. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33325. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33326. * 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)
  33327. */
  33328. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33329. /**
  33330. * This Observable will when a mesh has been imported into the scene.
  33331. */
  33332. onMeshImportedObservable: Observable<AbstractMesh>;
  33333. /**
  33334. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33335. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33336. */
  33337. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33338. /** @hidden */
  33339. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33340. /**
  33341. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33342. */
  33343. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33344. /**
  33345. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33346. */
  33347. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33348. /**
  33349. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33350. */
  33351. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33352. /** Callback called when a pointer move is detected */
  33353. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33354. /** Callback called when a pointer down is detected */
  33355. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33356. /** Callback called when a pointer up is detected */
  33357. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33358. /** Callback called when a pointer pick is detected */
  33359. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33360. /**
  33361. * 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).
  33362. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33363. */
  33364. onPrePointerObservable: Observable<PointerInfoPre>;
  33365. /**
  33366. * Observable event triggered each time an input event is received from the rendering canvas
  33367. */
  33368. onPointerObservable: Observable<PointerInfo>;
  33369. /**
  33370. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33371. */
  33372. readonly unTranslatedPointer: Vector2;
  33373. /**
  33374. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33375. */
  33376. static DragMovementThreshold: number;
  33377. /**
  33378. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33379. */
  33380. static LongPressDelay: number;
  33381. /**
  33382. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33383. */
  33384. static DoubleClickDelay: number;
  33385. /** If you need to check double click without raising a single click at first click, enable this flag */
  33386. static ExclusiveDoubleClickMode: boolean;
  33387. /** @hidden */
  33388. _mirroredCameraPosition: Nullable<Vector3>;
  33389. /**
  33390. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33391. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33392. */
  33393. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33394. /**
  33395. * Observable event triggered each time an keyboard event is received from the hosting window
  33396. */
  33397. onKeyboardObservable: Observable<KeyboardInfo>;
  33398. private _useRightHandedSystem;
  33399. /**
  33400. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33401. */
  33402. useRightHandedSystem: boolean;
  33403. private _timeAccumulator;
  33404. private _currentStepId;
  33405. private _currentInternalStep;
  33406. /**
  33407. * Sets the step Id used by deterministic lock step
  33408. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33409. * @param newStepId defines the step Id
  33410. */
  33411. setStepId(newStepId: number): void;
  33412. /**
  33413. * Gets the step Id used by deterministic lock step
  33414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33415. * @returns the step Id
  33416. */
  33417. getStepId(): number;
  33418. /**
  33419. * Gets the internal step used by deterministic lock step
  33420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33421. * @returns the internal step
  33422. */
  33423. getInternalStep(): number;
  33424. private _fogEnabled;
  33425. /**
  33426. * Gets or sets a boolean indicating if fog is enabled on this scene
  33427. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33428. * (Default is true)
  33429. */
  33430. fogEnabled: boolean;
  33431. private _fogMode;
  33432. /**
  33433. * Gets or sets the fog mode to use
  33434. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33435. * | mode | value |
  33436. * | --- | --- |
  33437. * | FOGMODE_NONE | 0 |
  33438. * | FOGMODE_EXP | 1 |
  33439. * | FOGMODE_EXP2 | 2 |
  33440. * | FOGMODE_LINEAR | 3 |
  33441. */
  33442. fogMode: number;
  33443. /**
  33444. * Gets or sets the fog color to use
  33445. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33446. * (Default is Color3(0.2, 0.2, 0.3))
  33447. */
  33448. fogColor: Color3;
  33449. /**
  33450. * Gets or sets the fog density to use
  33451. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33452. * (Default is 0.1)
  33453. */
  33454. fogDensity: number;
  33455. /**
  33456. * Gets or sets the fog start distance to use
  33457. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33458. * (Default is 0)
  33459. */
  33460. fogStart: number;
  33461. /**
  33462. * Gets or sets the fog end distance to use
  33463. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33464. * (Default is 1000)
  33465. */
  33466. fogEnd: number;
  33467. private _shadowsEnabled;
  33468. /**
  33469. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33470. */
  33471. shadowsEnabled: boolean;
  33472. private _lightsEnabled;
  33473. /**
  33474. * Gets or sets a boolean indicating if lights are enabled on this scene
  33475. */
  33476. lightsEnabled: boolean;
  33477. /** All of the active cameras added to this scene. */
  33478. activeCameras: Camera[];
  33479. /** @hidden */
  33480. _activeCamera: Nullable<Camera>;
  33481. /** Gets or sets the current active camera */
  33482. activeCamera: Nullable<Camera>;
  33483. private _defaultMaterial;
  33484. /** The default material used on meshes when no material is affected */
  33485. /** The default material used on meshes when no material is affected */
  33486. defaultMaterial: Material;
  33487. private _texturesEnabled;
  33488. /**
  33489. * Gets or sets a boolean indicating if textures are enabled on this scene
  33490. */
  33491. texturesEnabled: boolean;
  33492. /**
  33493. * Gets or sets a boolean indicating if particles are enabled on this scene
  33494. */
  33495. particlesEnabled: boolean;
  33496. /**
  33497. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33498. */
  33499. spritesEnabled: boolean;
  33500. private _skeletonsEnabled;
  33501. /**
  33502. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33503. */
  33504. skeletonsEnabled: boolean;
  33505. /**
  33506. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33507. */
  33508. lensFlaresEnabled: boolean;
  33509. /**
  33510. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33512. */
  33513. collisionsEnabled: boolean;
  33514. private _collisionCoordinator;
  33515. /** @hidden */
  33516. readonly collisionCoordinator: ICollisionCoordinator;
  33517. /**
  33518. * Defines the gravity applied to this scene (used only for collisions)
  33519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33520. */
  33521. gravity: Vector3;
  33522. /**
  33523. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33524. */
  33525. postProcessesEnabled: boolean;
  33526. /**
  33527. * The list of postprocesses added to the scene
  33528. */
  33529. postProcesses: PostProcess[];
  33530. /**
  33531. * Gets the current postprocess manager
  33532. */
  33533. postProcessManager: PostProcessManager;
  33534. /**
  33535. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33536. */
  33537. renderTargetsEnabled: boolean;
  33538. /**
  33539. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33540. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33541. */
  33542. dumpNextRenderTargets: boolean;
  33543. /**
  33544. * The list of user defined render targets added to the scene
  33545. */
  33546. customRenderTargets: RenderTargetTexture[];
  33547. /**
  33548. * Defines if texture loading must be delayed
  33549. * If true, textures will only be loaded when they need to be rendered
  33550. */
  33551. useDelayedTextureLoading: boolean;
  33552. /**
  33553. * Gets the list of meshes imported to the scene through SceneLoader
  33554. */
  33555. importedMeshesFiles: String[];
  33556. /**
  33557. * Gets or sets a boolean indicating if probes are enabled on this scene
  33558. */
  33559. probesEnabled: boolean;
  33560. /**
  33561. * Gets or sets the current offline provider to use to store scene data
  33562. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33563. */
  33564. offlineProvider: IOfflineProvider;
  33565. /**
  33566. * Gets or sets the action manager associated with the scene
  33567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33568. */
  33569. actionManager: AbstractActionManager;
  33570. private _meshesForIntersections;
  33571. /**
  33572. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33573. */
  33574. proceduralTexturesEnabled: boolean;
  33575. private _engine;
  33576. private _totalVertices;
  33577. /** @hidden */
  33578. _activeIndices: PerfCounter;
  33579. /** @hidden */
  33580. _activeParticles: PerfCounter;
  33581. /** @hidden */
  33582. _activeBones: PerfCounter;
  33583. private _animationRatio;
  33584. /** @hidden */
  33585. _animationTimeLast: number;
  33586. /** @hidden */
  33587. _animationTime: number;
  33588. /**
  33589. * Gets or sets a general scale for animation speed
  33590. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33591. */
  33592. animationTimeScale: number;
  33593. /** @hidden */
  33594. _cachedMaterial: Nullable<Material>;
  33595. /** @hidden */
  33596. _cachedEffect: Nullable<Effect>;
  33597. /** @hidden */
  33598. _cachedVisibility: Nullable<number>;
  33599. private _renderId;
  33600. private _frameId;
  33601. private _executeWhenReadyTimeoutId;
  33602. private _intermediateRendering;
  33603. private _viewUpdateFlag;
  33604. private _projectionUpdateFlag;
  33605. /** @hidden */
  33606. _toBeDisposed: Nullable<IDisposable>[];
  33607. private _activeRequests;
  33608. /** @hidden */
  33609. _pendingData: any[];
  33610. private _isDisposed;
  33611. /**
  33612. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33613. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33614. */
  33615. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33616. private _activeMeshes;
  33617. private _processedMaterials;
  33618. private _renderTargets;
  33619. /** @hidden */
  33620. _activeParticleSystems: SmartArray<IParticleSystem>;
  33621. private _activeSkeletons;
  33622. private _softwareSkinnedMeshes;
  33623. private _renderingManager;
  33624. /** @hidden */
  33625. _activeAnimatables: Animatable[];
  33626. private _transformMatrix;
  33627. private _sceneUbo;
  33628. /** @hidden */
  33629. _viewMatrix: Matrix;
  33630. private _projectionMatrix;
  33631. /** @hidden */
  33632. _forcedViewPosition: Nullable<Vector3>;
  33633. /** @hidden */
  33634. _frustumPlanes: Plane[];
  33635. /**
  33636. * Gets the list of frustum planes (built from the active camera)
  33637. */
  33638. readonly frustumPlanes: Plane[];
  33639. /**
  33640. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33641. * This is useful if there are more lights that the maximum simulteanous authorized
  33642. */
  33643. requireLightSorting: boolean;
  33644. /** @hidden */
  33645. readonly useMaterialMeshMap: boolean;
  33646. /** @hidden */
  33647. readonly useClonedMeshhMap: boolean;
  33648. private _externalData;
  33649. private _uid;
  33650. /**
  33651. * @hidden
  33652. * Backing store of defined scene components.
  33653. */
  33654. _components: ISceneComponent[];
  33655. /**
  33656. * @hidden
  33657. * Backing store of defined scene components.
  33658. */
  33659. _serializableComponents: ISceneSerializableComponent[];
  33660. /**
  33661. * List of components to register on the next registration step.
  33662. */
  33663. private _transientComponents;
  33664. /**
  33665. * Registers the transient components if needed.
  33666. */
  33667. private _registerTransientComponents;
  33668. /**
  33669. * @hidden
  33670. * Add a component to the scene.
  33671. * Note that the ccomponent could be registered on th next frame if this is called after
  33672. * the register component stage.
  33673. * @param component Defines the component to add to the scene
  33674. */
  33675. _addComponent(component: ISceneComponent): void;
  33676. /**
  33677. * @hidden
  33678. * Gets a component from the scene.
  33679. * @param name defines the name of the component to retrieve
  33680. * @returns the component or null if not present
  33681. */
  33682. _getComponent(name: string): Nullable<ISceneComponent>;
  33683. /**
  33684. * @hidden
  33685. * Defines the actions happening before camera updates.
  33686. */
  33687. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33688. /**
  33689. * @hidden
  33690. * Defines the actions happening before clear the canvas.
  33691. */
  33692. _beforeClearStage: Stage<SimpleStageAction>;
  33693. /**
  33694. * @hidden
  33695. * Defines the actions when collecting render targets for the frame.
  33696. */
  33697. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33698. /**
  33699. * @hidden
  33700. * Defines the actions happening for one camera in the frame.
  33701. */
  33702. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33703. /**
  33704. * @hidden
  33705. * Defines the actions happening during the per mesh ready checks.
  33706. */
  33707. _isReadyForMeshStage: Stage<MeshStageAction>;
  33708. /**
  33709. * @hidden
  33710. * Defines the actions happening before evaluate active mesh checks.
  33711. */
  33712. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33713. /**
  33714. * @hidden
  33715. * Defines the actions happening during the evaluate sub mesh checks.
  33716. */
  33717. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33718. /**
  33719. * @hidden
  33720. * Defines the actions happening during the active mesh stage.
  33721. */
  33722. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33723. /**
  33724. * @hidden
  33725. * Defines the actions happening during the per camera render target step.
  33726. */
  33727. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33728. /**
  33729. * @hidden
  33730. * Defines the actions happening just before the active camera is drawing.
  33731. */
  33732. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33733. /**
  33734. * @hidden
  33735. * Defines the actions happening just before a render target is drawing.
  33736. */
  33737. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33738. /**
  33739. * @hidden
  33740. * Defines the actions happening just before a rendering group is drawing.
  33741. */
  33742. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33743. /**
  33744. * @hidden
  33745. * Defines the actions happening just before a mesh is drawing.
  33746. */
  33747. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33748. /**
  33749. * @hidden
  33750. * Defines the actions happening just after a mesh has been drawn.
  33751. */
  33752. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33753. /**
  33754. * @hidden
  33755. * Defines the actions happening just after a rendering group has been drawn.
  33756. */
  33757. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33758. /**
  33759. * @hidden
  33760. * Defines the actions happening just after the active camera has been drawn.
  33761. */
  33762. _afterCameraDrawStage: Stage<CameraStageAction>;
  33763. /**
  33764. * @hidden
  33765. * Defines the actions happening just after a render target has been drawn.
  33766. */
  33767. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33768. /**
  33769. * @hidden
  33770. * Defines the actions happening just after rendering all cameras and computing intersections.
  33771. */
  33772. _afterRenderStage: Stage<SimpleStageAction>;
  33773. /**
  33774. * @hidden
  33775. * Defines the actions happening when a pointer move event happens.
  33776. */
  33777. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33778. /**
  33779. * @hidden
  33780. * Defines the actions happening when a pointer down event happens.
  33781. */
  33782. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33783. /**
  33784. * @hidden
  33785. * Defines the actions happening when a pointer up event happens.
  33786. */
  33787. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33788. /**
  33789. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33790. */
  33791. private geometriesByUniqueId;
  33792. /**
  33793. * Creates a new Scene
  33794. * @param engine defines the engine to use to render this scene
  33795. * @param options defines the scene options
  33796. */
  33797. constructor(engine: Engine, options?: SceneOptions);
  33798. /**
  33799. * Gets a string idenfifying the name of the class
  33800. * @returns "Scene" string
  33801. */
  33802. getClassName(): string;
  33803. private _defaultMeshCandidates;
  33804. /**
  33805. * @hidden
  33806. */
  33807. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33808. private _defaultSubMeshCandidates;
  33809. /**
  33810. * @hidden
  33811. */
  33812. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33813. /**
  33814. * Sets the default candidate providers for the scene.
  33815. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33816. * and getCollidingSubMeshCandidates to their default function
  33817. */
  33818. setDefaultCandidateProviders(): void;
  33819. /**
  33820. * Gets the mesh that is currently under the pointer
  33821. */
  33822. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33823. /**
  33824. * Gets or sets the current on-screen X position of the pointer
  33825. */
  33826. pointerX: number;
  33827. /**
  33828. * Gets or sets the current on-screen Y position of the pointer
  33829. */
  33830. pointerY: number;
  33831. /**
  33832. * Gets the cached material (ie. the latest rendered one)
  33833. * @returns the cached material
  33834. */
  33835. getCachedMaterial(): Nullable<Material>;
  33836. /**
  33837. * Gets the cached effect (ie. the latest rendered one)
  33838. * @returns the cached effect
  33839. */
  33840. getCachedEffect(): Nullable<Effect>;
  33841. /**
  33842. * Gets the cached visibility state (ie. the latest rendered one)
  33843. * @returns the cached visibility state
  33844. */
  33845. getCachedVisibility(): Nullable<number>;
  33846. /**
  33847. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33848. * @param material defines the current material
  33849. * @param effect defines the current effect
  33850. * @param visibility defines the current visibility state
  33851. * @returns true if one parameter is not cached
  33852. */
  33853. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33854. /**
  33855. * Gets the engine associated with the scene
  33856. * @returns an Engine
  33857. */
  33858. getEngine(): Engine;
  33859. /**
  33860. * Gets the total number of vertices rendered per frame
  33861. * @returns the total number of vertices rendered per frame
  33862. */
  33863. getTotalVertices(): number;
  33864. /**
  33865. * Gets the performance counter for total vertices
  33866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33867. */
  33868. readonly totalVerticesPerfCounter: PerfCounter;
  33869. /**
  33870. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33871. * @returns the total number of active indices rendered per frame
  33872. */
  33873. getActiveIndices(): number;
  33874. /**
  33875. * Gets the performance counter for active indices
  33876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33877. */
  33878. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33879. /**
  33880. * Gets the total number of active particles rendered per frame
  33881. * @returns the total number of active particles rendered per frame
  33882. */
  33883. getActiveParticles(): number;
  33884. /**
  33885. * Gets the performance counter for active particles
  33886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33887. */
  33888. readonly activeParticlesPerfCounter: PerfCounter;
  33889. /**
  33890. * Gets the total number of active bones rendered per frame
  33891. * @returns the total number of active bones rendered per frame
  33892. */
  33893. getActiveBones(): number;
  33894. /**
  33895. * Gets the performance counter for active bones
  33896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33897. */
  33898. readonly activeBonesPerfCounter: PerfCounter;
  33899. /**
  33900. * Gets the array of active meshes
  33901. * @returns an array of AbstractMesh
  33902. */
  33903. getActiveMeshes(): SmartArray<AbstractMesh>;
  33904. /**
  33905. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33906. * @returns a number
  33907. */
  33908. getAnimationRatio(): number;
  33909. /**
  33910. * Gets an unique Id for the current render phase
  33911. * @returns a number
  33912. */
  33913. getRenderId(): number;
  33914. /**
  33915. * Gets an unique Id for the current frame
  33916. * @returns a number
  33917. */
  33918. getFrameId(): number;
  33919. /** Call this function if you want to manually increment the render Id*/
  33920. incrementRenderId(): void;
  33921. private _createUbo;
  33922. /**
  33923. * Use this method to simulate a pointer move on a mesh
  33924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33927. * @returns the current scene
  33928. */
  33929. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33930. /**
  33931. * Use this method to simulate a pointer down on a mesh
  33932. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33933. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33934. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33935. * @returns the current scene
  33936. */
  33937. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33938. /**
  33939. * Use this method to simulate a pointer up on a mesh
  33940. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33941. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33942. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33943. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33944. * @returns the current scene
  33945. */
  33946. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33947. /**
  33948. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33949. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33950. * @returns true if the pointer was captured
  33951. */
  33952. isPointerCaptured(pointerId?: number): boolean;
  33953. /**
  33954. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33955. * @param attachUp defines if you want to attach events to pointerup
  33956. * @param attachDown defines if you want to attach events to pointerdown
  33957. * @param attachMove defines if you want to attach events to pointermove
  33958. */
  33959. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33960. /** Detaches all event handlers*/
  33961. detachControl(): void;
  33962. /**
  33963. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33964. * Delay loaded resources are not taking in account
  33965. * @return true if all required resources are ready
  33966. */
  33967. isReady(): boolean;
  33968. /** Resets all cached information relative to material (including effect and visibility) */
  33969. resetCachedMaterial(): void;
  33970. /**
  33971. * Registers a function to be called before every frame render
  33972. * @param func defines the function to register
  33973. */
  33974. registerBeforeRender(func: () => void): void;
  33975. /**
  33976. * Unregisters a function called before every frame render
  33977. * @param func defines the function to unregister
  33978. */
  33979. unregisterBeforeRender(func: () => void): void;
  33980. /**
  33981. * Registers a function to be called after every frame render
  33982. * @param func defines the function to register
  33983. */
  33984. registerAfterRender(func: () => void): void;
  33985. /**
  33986. * Unregisters a function called after every frame render
  33987. * @param func defines the function to unregister
  33988. */
  33989. unregisterAfterRender(func: () => void): void;
  33990. private _executeOnceBeforeRender;
  33991. /**
  33992. * The provided function will run before render once and will be disposed afterwards.
  33993. * A timeout delay can be provided so that the function will be executed in N ms.
  33994. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33995. * @param func The function to be executed.
  33996. * @param timeout optional delay in ms
  33997. */
  33998. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33999. /** @hidden */
  34000. _addPendingData(data: any): void;
  34001. /** @hidden */
  34002. _removePendingData(data: any): void;
  34003. /**
  34004. * Returns the number of items waiting to be loaded
  34005. * @returns the number of items waiting to be loaded
  34006. */
  34007. getWaitingItemsCount(): number;
  34008. /**
  34009. * Returns a boolean indicating if the scene is still loading data
  34010. */
  34011. readonly isLoading: boolean;
  34012. /**
  34013. * Registers a function to be executed when the scene is ready
  34014. * @param {Function} func - the function to be executed
  34015. */
  34016. executeWhenReady(func: () => void): void;
  34017. /**
  34018. * Returns a promise that resolves when the scene is ready
  34019. * @returns A promise that resolves when the scene is ready
  34020. */
  34021. whenReadyAsync(): Promise<void>;
  34022. /** @hidden */
  34023. _checkIsReady(): void;
  34024. /**
  34025. * Gets all animatable attached to the scene
  34026. */
  34027. readonly animatables: Animatable[];
  34028. /**
  34029. * Resets the last animation time frame.
  34030. * Useful to override when animations start running when loading a scene for the first time.
  34031. */
  34032. resetLastAnimationTimeFrame(): void;
  34033. /**
  34034. * Gets the current view matrix
  34035. * @returns a Matrix
  34036. */
  34037. getViewMatrix(): Matrix;
  34038. /**
  34039. * Gets the current projection matrix
  34040. * @returns a Matrix
  34041. */
  34042. getProjectionMatrix(): Matrix;
  34043. /**
  34044. * Gets the current transform matrix
  34045. * @returns a Matrix made of View * Projection
  34046. */
  34047. getTransformMatrix(): Matrix;
  34048. /**
  34049. * Sets the current transform matrix
  34050. * @param viewL defines the View matrix to use
  34051. * @param projectionL defines the Projection matrix to use
  34052. * @param viewR defines the right View matrix to use (if provided)
  34053. * @param projectionR defines the right Projection matrix to use (if provided)
  34054. */
  34055. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34056. /**
  34057. * Gets the uniform buffer used to store scene data
  34058. * @returns a UniformBuffer
  34059. */
  34060. getSceneUniformBuffer(): UniformBuffer;
  34061. /**
  34062. * Gets an unique (relatively to the current scene) Id
  34063. * @returns an unique number for the scene
  34064. */
  34065. getUniqueId(): number;
  34066. /**
  34067. * Add a mesh to the list of scene's meshes
  34068. * @param newMesh defines the mesh to add
  34069. * @param recursive if all child meshes should also be added to the scene
  34070. */
  34071. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34072. /**
  34073. * Remove a mesh for the list of scene's meshes
  34074. * @param toRemove defines the mesh to remove
  34075. * @param recursive if all child meshes should also be removed from the scene
  34076. * @returns the index where the mesh was in the mesh list
  34077. */
  34078. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34079. /**
  34080. * Add a transform node to the list of scene's transform nodes
  34081. * @param newTransformNode defines the transform node to add
  34082. */
  34083. addTransformNode(newTransformNode: TransformNode): void;
  34084. /**
  34085. * Remove a transform node for the list of scene's transform nodes
  34086. * @param toRemove defines the transform node to remove
  34087. * @returns the index where the transform node was in the transform node list
  34088. */
  34089. removeTransformNode(toRemove: TransformNode): number;
  34090. /**
  34091. * Remove a skeleton for the list of scene's skeletons
  34092. * @param toRemove defines the skeleton to remove
  34093. * @returns the index where the skeleton was in the skeleton list
  34094. */
  34095. removeSkeleton(toRemove: Skeleton): number;
  34096. /**
  34097. * Remove a morph target for the list of scene's morph targets
  34098. * @param toRemove defines the morph target to remove
  34099. * @returns the index where the morph target was in the morph target list
  34100. */
  34101. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34102. /**
  34103. * Remove a light for the list of scene's lights
  34104. * @param toRemove defines the light to remove
  34105. * @returns the index where the light was in the light list
  34106. */
  34107. removeLight(toRemove: Light): number;
  34108. /**
  34109. * Remove a camera for the list of scene's cameras
  34110. * @param toRemove defines the camera to remove
  34111. * @returns the index where the camera was in the camera list
  34112. */
  34113. removeCamera(toRemove: Camera): number;
  34114. /**
  34115. * Remove a particle system for the list of scene's particle systems
  34116. * @param toRemove defines the particle system to remove
  34117. * @returns the index where the particle system was in the particle system list
  34118. */
  34119. removeParticleSystem(toRemove: IParticleSystem): number;
  34120. /**
  34121. * Remove a animation for the list of scene's animations
  34122. * @param toRemove defines the animation to remove
  34123. * @returns the index where the animation was in the animation list
  34124. */
  34125. removeAnimation(toRemove: Animation): number;
  34126. /**
  34127. * Will stop the animation of the given target
  34128. * @param target - the target
  34129. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34130. * @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)
  34131. */
  34132. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34133. /**
  34134. * Removes the given animation group from this scene.
  34135. * @param toRemove The animation group to remove
  34136. * @returns The index of the removed animation group
  34137. */
  34138. removeAnimationGroup(toRemove: AnimationGroup): number;
  34139. /**
  34140. * Removes the given multi-material from this scene.
  34141. * @param toRemove The multi-material to remove
  34142. * @returns The index of the removed multi-material
  34143. */
  34144. removeMultiMaterial(toRemove: MultiMaterial): number;
  34145. /**
  34146. * Removes the given material from this scene.
  34147. * @param toRemove The material to remove
  34148. * @returns The index of the removed material
  34149. */
  34150. removeMaterial(toRemove: Material): number;
  34151. /**
  34152. * Removes the given action manager from this scene.
  34153. * @param toRemove The action manager to remove
  34154. * @returns The index of the removed action manager
  34155. */
  34156. removeActionManager(toRemove: AbstractActionManager): number;
  34157. /**
  34158. * Removes the given texture from this scene.
  34159. * @param toRemove The texture to remove
  34160. * @returns The index of the removed texture
  34161. */
  34162. removeTexture(toRemove: BaseTexture): number;
  34163. /**
  34164. * Adds the given light to this scene
  34165. * @param newLight The light to add
  34166. */
  34167. addLight(newLight: Light): void;
  34168. /**
  34169. * Sorts the list list based on light priorities
  34170. */
  34171. sortLightsByPriority(): void;
  34172. /**
  34173. * Adds the given camera to this scene
  34174. * @param newCamera The camera to add
  34175. */
  34176. addCamera(newCamera: Camera): void;
  34177. /**
  34178. * Adds the given skeleton to this scene
  34179. * @param newSkeleton The skeleton to add
  34180. */
  34181. addSkeleton(newSkeleton: Skeleton): void;
  34182. /**
  34183. * Adds the given particle system to this scene
  34184. * @param newParticleSystem The particle system to add
  34185. */
  34186. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34187. /**
  34188. * Adds the given animation to this scene
  34189. * @param newAnimation The animation to add
  34190. */
  34191. addAnimation(newAnimation: Animation): void;
  34192. /**
  34193. * Adds the given animation group to this scene.
  34194. * @param newAnimationGroup The animation group to add
  34195. */
  34196. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34197. /**
  34198. * Adds the given multi-material to this scene
  34199. * @param newMultiMaterial The multi-material to add
  34200. */
  34201. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34202. /**
  34203. * Adds the given material to this scene
  34204. * @param newMaterial The material to add
  34205. */
  34206. addMaterial(newMaterial: Material): void;
  34207. /**
  34208. * Adds the given morph target to this scene
  34209. * @param newMorphTargetManager The morph target to add
  34210. */
  34211. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34212. /**
  34213. * Adds the given geometry to this scene
  34214. * @param newGeometry The geometry to add
  34215. */
  34216. addGeometry(newGeometry: Geometry): void;
  34217. /**
  34218. * Adds the given action manager to this scene
  34219. * @param newActionManager The action manager to add
  34220. */
  34221. addActionManager(newActionManager: AbstractActionManager): void;
  34222. /**
  34223. * Adds the given texture to this scene.
  34224. * @param newTexture The texture to add
  34225. */
  34226. addTexture(newTexture: BaseTexture): void;
  34227. /**
  34228. * Switch active camera
  34229. * @param newCamera defines the new active camera
  34230. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34231. */
  34232. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34233. /**
  34234. * sets the active camera of the scene using its ID
  34235. * @param id defines the camera's ID
  34236. * @return the new active camera or null if none found.
  34237. */
  34238. setActiveCameraByID(id: string): Nullable<Camera>;
  34239. /**
  34240. * sets the active camera of the scene using its name
  34241. * @param name defines the camera's name
  34242. * @returns the new active camera or null if none found.
  34243. */
  34244. setActiveCameraByName(name: string): Nullable<Camera>;
  34245. /**
  34246. * get an animation group using its name
  34247. * @param name defines the material's name
  34248. * @return the animation group or null if none found.
  34249. */
  34250. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34251. /**
  34252. * Get a material using its unique id
  34253. * @param uniqueId defines the material's unique id
  34254. * @return the material or null if none found.
  34255. */
  34256. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34257. /**
  34258. * get a material using its id
  34259. * @param id defines the material's ID
  34260. * @return the material or null if none found.
  34261. */
  34262. getMaterialByID(id: string): Nullable<Material>;
  34263. /**
  34264. * Gets a the last added material using a given id
  34265. * @param id defines the material's ID
  34266. * @return the last material with the given id or null if none found.
  34267. */
  34268. getLastMaterialByID(id: string): Nullable<Material>;
  34269. /**
  34270. * Gets a material using its name
  34271. * @param name defines the material's name
  34272. * @return the material or null if none found.
  34273. */
  34274. getMaterialByName(name: string): Nullable<Material>;
  34275. /**
  34276. * Get a texture using its unique id
  34277. * @param uniqueId defines the texture's unique id
  34278. * @return the texture or null if none found.
  34279. */
  34280. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34281. /**
  34282. * Gets a camera using its id
  34283. * @param id defines the id to look for
  34284. * @returns the camera or null if not found
  34285. */
  34286. getCameraByID(id: string): Nullable<Camera>;
  34287. /**
  34288. * Gets a camera using its unique id
  34289. * @param uniqueId defines the unique id to look for
  34290. * @returns the camera or null if not found
  34291. */
  34292. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34293. /**
  34294. * Gets a camera using its name
  34295. * @param name defines the camera's name
  34296. * @return the camera or null if none found.
  34297. */
  34298. getCameraByName(name: string): Nullable<Camera>;
  34299. /**
  34300. * Gets a bone using its id
  34301. * @param id defines the bone's id
  34302. * @return the bone or null if not found
  34303. */
  34304. getBoneByID(id: string): Nullable<Bone>;
  34305. /**
  34306. * Gets a bone using its id
  34307. * @param name defines the bone's name
  34308. * @return the bone or null if not found
  34309. */
  34310. getBoneByName(name: string): Nullable<Bone>;
  34311. /**
  34312. * Gets a light node using its name
  34313. * @param name defines the the light's name
  34314. * @return the light or null if none found.
  34315. */
  34316. getLightByName(name: string): Nullable<Light>;
  34317. /**
  34318. * Gets a light node using its id
  34319. * @param id defines the light's id
  34320. * @return the light or null if none found.
  34321. */
  34322. getLightByID(id: string): Nullable<Light>;
  34323. /**
  34324. * Gets a light node using its scene-generated unique ID
  34325. * @param uniqueId defines the light's unique id
  34326. * @return the light or null if none found.
  34327. */
  34328. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34329. /**
  34330. * Gets a particle system by id
  34331. * @param id defines the particle system id
  34332. * @return the corresponding system or null if none found
  34333. */
  34334. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34335. /**
  34336. * Gets a geometry using its ID
  34337. * @param id defines the geometry's id
  34338. * @return the geometry or null if none found.
  34339. */
  34340. getGeometryByID(id: string): Nullable<Geometry>;
  34341. private _getGeometryByUniqueID;
  34342. /**
  34343. * Add a new geometry to this scene
  34344. * @param geometry defines the geometry to be added to the scene.
  34345. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34346. * @return a boolean defining if the geometry was added or not
  34347. */
  34348. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34349. /**
  34350. * Removes an existing geometry
  34351. * @param geometry defines the geometry to be removed from the scene
  34352. * @return a boolean defining if the geometry was removed or not
  34353. */
  34354. removeGeometry(geometry: Geometry): boolean;
  34355. /**
  34356. * Gets the list of geometries attached to the scene
  34357. * @returns an array of Geometry
  34358. */
  34359. getGeometries(): Geometry[];
  34360. /**
  34361. * Gets the first added mesh found of a given ID
  34362. * @param id defines the id to search for
  34363. * @return the mesh found or null if not found at all
  34364. */
  34365. getMeshByID(id: string): Nullable<AbstractMesh>;
  34366. /**
  34367. * Gets a list of meshes using their id
  34368. * @param id defines the id to search for
  34369. * @returns a list of meshes
  34370. */
  34371. getMeshesByID(id: string): Array<AbstractMesh>;
  34372. /**
  34373. * Gets the first added transform node found of a given ID
  34374. * @param id defines the id to search for
  34375. * @return the found transform node or null if not found at all.
  34376. */
  34377. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34378. /**
  34379. * Gets a transform node with its auto-generated unique id
  34380. * @param uniqueId efines the unique id to search for
  34381. * @return the found transform node or null if not found at all.
  34382. */
  34383. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34384. /**
  34385. * Gets a list of transform nodes using their id
  34386. * @param id defines the id to search for
  34387. * @returns a list of transform nodes
  34388. */
  34389. getTransformNodesByID(id: string): Array<TransformNode>;
  34390. /**
  34391. * Gets a mesh with its auto-generated unique id
  34392. * @param uniqueId defines the unique id to search for
  34393. * @return the found mesh or null if not found at all.
  34394. */
  34395. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34396. /**
  34397. * Gets a the last added mesh using a given id
  34398. * @param id defines the id to search for
  34399. * @return the found mesh or null if not found at all.
  34400. */
  34401. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34402. /**
  34403. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34404. * @param id defines the id to search for
  34405. * @return the found node or null if not found at all
  34406. */
  34407. getLastEntryByID(id: string): Nullable<Node>;
  34408. /**
  34409. * Gets a node (Mesh, Camera, Light) using a given id
  34410. * @param id defines the id to search for
  34411. * @return the found node or null if not found at all
  34412. */
  34413. getNodeByID(id: string): Nullable<Node>;
  34414. /**
  34415. * Gets a node (Mesh, Camera, Light) using a given name
  34416. * @param name defines the name to search for
  34417. * @return the found node or null if not found at all.
  34418. */
  34419. getNodeByName(name: string): Nullable<Node>;
  34420. /**
  34421. * Gets a mesh using a given name
  34422. * @param name defines the name to search for
  34423. * @return the found mesh or null if not found at all.
  34424. */
  34425. getMeshByName(name: string): Nullable<AbstractMesh>;
  34426. /**
  34427. * Gets a transform node using a given name
  34428. * @param name defines the name to search for
  34429. * @return the found transform node or null if not found at all.
  34430. */
  34431. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34432. /**
  34433. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34434. * @param id defines the id to search for
  34435. * @return the found skeleton or null if not found at all.
  34436. */
  34437. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34438. /**
  34439. * Gets a skeleton using a given auto generated unique id
  34440. * @param uniqueId defines the unique id to search for
  34441. * @return the found skeleton or null if not found at all.
  34442. */
  34443. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34444. /**
  34445. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34446. * @param id defines the id to search for
  34447. * @return the found skeleton or null if not found at all.
  34448. */
  34449. getSkeletonById(id: string): Nullable<Skeleton>;
  34450. /**
  34451. * Gets a skeleton using a given name
  34452. * @param name defines the name to search for
  34453. * @return the found skeleton or null if not found at all.
  34454. */
  34455. getSkeletonByName(name: string): Nullable<Skeleton>;
  34456. /**
  34457. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34458. * @param id defines the id to search for
  34459. * @return the found morph target manager or null if not found at all.
  34460. */
  34461. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34462. /**
  34463. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34464. * @param id defines the id to search for
  34465. * @return the found morph target or null if not found at all.
  34466. */
  34467. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34468. /**
  34469. * Gets a boolean indicating if the given mesh is active
  34470. * @param mesh defines the mesh to look for
  34471. * @returns true if the mesh is in the active list
  34472. */
  34473. isActiveMesh(mesh: AbstractMesh): boolean;
  34474. /**
  34475. * Return a unique id as a string which can serve as an identifier for the scene
  34476. */
  34477. readonly uid: string;
  34478. /**
  34479. * Add an externaly attached data from its key.
  34480. * This method call will fail and return false, if such key already exists.
  34481. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34482. * @param key the unique key that identifies the data
  34483. * @param data the data object to associate to the key for this Engine instance
  34484. * @return true if no such key were already present and the data was added successfully, false otherwise
  34485. */
  34486. addExternalData<T>(key: string, data: T): boolean;
  34487. /**
  34488. * Get an externaly attached data from its key
  34489. * @param key the unique key that identifies the data
  34490. * @return the associated data, if present (can be null), or undefined if not present
  34491. */
  34492. getExternalData<T>(key: string): Nullable<T>;
  34493. /**
  34494. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34495. * @param key the unique key that identifies the data
  34496. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34497. * @return the associated data, can be null if the factory returned null.
  34498. */
  34499. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34500. /**
  34501. * Remove an externaly attached data from the Engine instance
  34502. * @param key the unique key that identifies the data
  34503. * @return true if the data was successfully removed, false if it doesn't exist
  34504. */
  34505. removeExternalData(key: string): boolean;
  34506. private _evaluateSubMesh;
  34507. /**
  34508. * Clear the processed materials smart array preventing retention point in material dispose.
  34509. */
  34510. freeProcessedMaterials(): void;
  34511. private _preventFreeActiveMeshesAndRenderingGroups;
  34512. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34513. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34514. * when disposing several meshes in a row or a hierarchy of meshes.
  34515. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34516. */
  34517. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34518. /**
  34519. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34520. */
  34521. freeActiveMeshes(): void;
  34522. /**
  34523. * Clear the info related to rendering groups preventing retention points during dispose.
  34524. */
  34525. freeRenderingGroups(): void;
  34526. /** @hidden */
  34527. _isInIntermediateRendering(): boolean;
  34528. /**
  34529. * Lambda returning the list of potentially active meshes.
  34530. */
  34531. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34532. /**
  34533. * Lambda returning the list of potentially active sub meshes.
  34534. */
  34535. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34536. /**
  34537. * Lambda returning the list of potentially intersecting sub meshes.
  34538. */
  34539. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34540. /**
  34541. * Lambda returning the list of potentially colliding sub meshes.
  34542. */
  34543. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34544. private _activeMeshesFrozen;
  34545. /**
  34546. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34547. * @returns the current scene
  34548. */
  34549. freezeActiveMeshes(): Scene;
  34550. /**
  34551. * Use this function to restart evaluating active meshes on every frame
  34552. * @returns the current scene
  34553. */
  34554. unfreezeActiveMeshes(): Scene;
  34555. private _evaluateActiveMeshes;
  34556. private _activeMesh;
  34557. /**
  34558. * Update the transform matrix to update from the current active camera
  34559. * @param force defines a boolean used to force the update even if cache is up to date
  34560. */
  34561. updateTransformMatrix(force?: boolean): void;
  34562. private _bindFrameBuffer;
  34563. /** @hidden */
  34564. _allowPostProcessClearColor: boolean;
  34565. /** @hidden */
  34566. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34567. private _processSubCameras;
  34568. private _checkIntersections;
  34569. /** @hidden */
  34570. _advancePhysicsEngineStep(step: number): void;
  34571. /**
  34572. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34573. */
  34574. getDeterministicFrameTime: () => number;
  34575. /** @hidden */
  34576. _animate(): void;
  34577. /** Execute all animations (for a frame) */
  34578. animate(): void;
  34579. /**
  34580. * Render the scene
  34581. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34582. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34583. */
  34584. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34585. /**
  34586. * Freeze all materials
  34587. * A frozen material will not be updatable but should be faster to render
  34588. */
  34589. freezeMaterials(): void;
  34590. /**
  34591. * Unfreeze all materials
  34592. * A frozen material will not be updatable but should be faster to render
  34593. */
  34594. unfreezeMaterials(): void;
  34595. /**
  34596. * Releases all held ressources
  34597. */
  34598. dispose(): void;
  34599. /**
  34600. * Gets if the scene is already disposed
  34601. */
  34602. readonly isDisposed: boolean;
  34603. /**
  34604. * Call this function to reduce memory footprint of the scene.
  34605. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34606. */
  34607. clearCachedVertexData(): void;
  34608. /**
  34609. * This function will remove the local cached buffer data from texture.
  34610. * It will save memory but will prevent the texture from being rebuilt
  34611. */
  34612. cleanCachedTextureBuffer(): void;
  34613. /**
  34614. * Get the world extend vectors with an optional filter
  34615. *
  34616. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34617. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34618. */
  34619. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34620. min: Vector3;
  34621. max: Vector3;
  34622. };
  34623. /**
  34624. * Creates a ray that can be used to pick in the scene
  34625. * @param x defines the x coordinate of the origin (on-screen)
  34626. * @param y defines the y coordinate of the origin (on-screen)
  34627. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34628. * @param camera defines the camera to use for the picking
  34629. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34630. * @returns a Ray
  34631. */
  34632. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34633. /**
  34634. * Creates a ray that can be used to pick in the scene
  34635. * @param x defines the x coordinate of the origin (on-screen)
  34636. * @param y defines the y coordinate of the origin (on-screen)
  34637. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34638. * @param result defines the ray where to store the picking ray
  34639. * @param camera defines the camera to use for the picking
  34640. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34641. * @returns the current scene
  34642. */
  34643. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34644. /**
  34645. * Creates a ray that can be used to pick in the scene
  34646. * @param x defines the x coordinate of the origin (on-screen)
  34647. * @param y defines the y coordinate of the origin (on-screen)
  34648. * @param camera defines the camera to use for the picking
  34649. * @returns a Ray
  34650. */
  34651. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34652. /**
  34653. * Creates a ray that can be used to pick in the scene
  34654. * @param x defines the x coordinate of the origin (on-screen)
  34655. * @param y defines the y coordinate of the origin (on-screen)
  34656. * @param result defines the ray where to store the picking ray
  34657. * @param camera defines the camera to use for the picking
  34658. * @returns the current scene
  34659. */
  34660. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34661. /** Launch a ray to try to pick a mesh in the scene
  34662. * @param x position on screen
  34663. * @param y position on screen
  34664. * @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
  34665. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34666. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34667. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34668. * @returns a PickingInfo
  34669. */
  34670. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34671. /** Use the given ray to pick a mesh in the scene
  34672. * @param ray The ray to use to pick meshes
  34673. * @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
  34674. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34675. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34676. * @returns a PickingInfo
  34677. */
  34678. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34679. /**
  34680. * Launch a ray to try to pick a mesh in the scene
  34681. * @param x X position on screen
  34682. * @param y Y position on screen
  34683. * @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
  34684. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34686. * @returns an array of PickingInfo
  34687. */
  34688. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34689. /**
  34690. * Launch a ray to try to pick a mesh in the scene
  34691. * @param ray Ray to use
  34692. * @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
  34693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34694. * @returns an array of PickingInfo
  34695. */
  34696. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34697. /**
  34698. * Force the value of meshUnderPointer
  34699. * @param mesh defines the mesh to use
  34700. */
  34701. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34702. /**
  34703. * Gets the mesh under the pointer
  34704. * @returns a Mesh or null if no mesh is under the pointer
  34705. */
  34706. getPointerOverMesh(): Nullable<AbstractMesh>;
  34707. /** @hidden */
  34708. _rebuildGeometries(): void;
  34709. /** @hidden */
  34710. _rebuildTextures(): void;
  34711. private _getByTags;
  34712. /**
  34713. * Get a list of meshes by tags
  34714. * @param tagsQuery defines the tags query to use
  34715. * @param forEach defines a predicate used to filter results
  34716. * @returns an array of Mesh
  34717. */
  34718. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34719. /**
  34720. * Get a list of cameras by tags
  34721. * @param tagsQuery defines the tags query to use
  34722. * @param forEach defines a predicate used to filter results
  34723. * @returns an array of Camera
  34724. */
  34725. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34726. /**
  34727. * Get a list of lights by tags
  34728. * @param tagsQuery defines the tags query to use
  34729. * @param forEach defines a predicate used to filter results
  34730. * @returns an array of Light
  34731. */
  34732. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34733. /**
  34734. * Get a list of materials by tags
  34735. * @param tagsQuery defines the tags query to use
  34736. * @param forEach defines a predicate used to filter results
  34737. * @returns an array of Material
  34738. */
  34739. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34740. /**
  34741. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34742. * This allowed control for front to back rendering or reversly depending of the special needs.
  34743. *
  34744. * @param renderingGroupId The rendering group id corresponding to its index
  34745. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34746. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34747. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34748. */
  34749. 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;
  34750. /**
  34751. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34752. *
  34753. * @param renderingGroupId The rendering group id corresponding to its index
  34754. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34755. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34756. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34757. */
  34758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34759. /**
  34760. * Gets the current auto clear configuration for one rendering group of the rendering
  34761. * manager.
  34762. * @param index the rendering group index to get the information for
  34763. * @returns The auto clear setup for the requested rendering group
  34764. */
  34765. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34766. private _blockMaterialDirtyMechanism;
  34767. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34768. blockMaterialDirtyMechanism: boolean;
  34769. /**
  34770. * Will flag all materials as dirty to trigger new shader compilation
  34771. * @param flag defines the flag used to specify which material part must be marked as dirty
  34772. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34773. */
  34774. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34775. /** @hidden */
  34776. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34777. /** @hidden */
  34778. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34779. }
  34780. }
  34781. declare module BABYLON {
  34782. /**
  34783. * Set of assets to keep when moving a scene into an asset container.
  34784. */
  34785. export class KeepAssets extends AbstractScene {
  34786. }
  34787. /**
  34788. * Container with a set of assets that can be added or removed from a scene.
  34789. */
  34790. export class AssetContainer extends AbstractScene {
  34791. /**
  34792. * The scene the AssetContainer belongs to.
  34793. */
  34794. scene: Scene;
  34795. /**
  34796. * Instantiates an AssetContainer.
  34797. * @param scene The scene the AssetContainer belongs to.
  34798. */
  34799. constructor(scene: Scene);
  34800. /**
  34801. * Adds all the assets from the container to the scene.
  34802. */
  34803. addAllToScene(): void;
  34804. /**
  34805. * Removes all the assets in the container from the scene
  34806. */
  34807. removeAllFromScene(): void;
  34808. /**
  34809. * Disposes all the assets in the container
  34810. */
  34811. dispose(): void;
  34812. private _moveAssets;
  34813. /**
  34814. * Removes all the assets contained in the scene and adds them to the container.
  34815. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34816. */
  34817. moveAllFromScene(keepAssets?: KeepAssets): void;
  34818. /**
  34819. * 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.
  34820. * @returns the root mesh
  34821. */
  34822. createRootMesh(): Mesh;
  34823. }
  34824. }
  34825. declare module BABYLON {
  34826. /**
  34827. * Defines how the parser contract is defined.
  34828. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34829. */
  34830. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34831. /**
  34832. * Defines how the individual parser contract is defined.
  34833. * These parser can parse an individual asset
  34834. */
  34835. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34836. /**
  34837. * Base class of the scene acting as a container for the different elements composing a scene.
  34838. * This class is dynamically extended by the different components of the scene increasing
  34839. * flexibility and reducing coupling
  34840. */
  34841. export abstract class AbstractScene {
  34842. /**
  34843. * Stores the list of available parsers in the application.
  34844. */
  34845. private static _BabylonFileParsers;
  34846. /**
  34847. * Stores the list of available individual parsers in the application.
  34848. */
  34849. private static _IndividualBabylonFileParsers;
  34850. /**
  34851. * Adds a parser in the list of available ones
  34852. * @param name Defines the name of the parser
  34853. * @param parser Defines the parser to add
  34854. */
  34855. static AddParser(name: string, parser: BabylonFileParser): void;
  34856. /**
  34857. * Gets a general parser from the list of avaialble ones
  34858. * @param name Defines the name of the parser
  34859. * @returns the requested parser or null
  34860. */
  34861. static GetParser(name: string): Nullable<BabylonFileParser>;
  34862. /**
  34863. * Adds n individual parser in the list of available ones
  34864. * @param name Defines the name of the parser
  34865. * @param parser Defines the parser to add
  34866. */
  34867. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34868. /**
  34869. * Gets an individual parser from the list of avaialble ones
  34870. * @param name Defines the name of the parser
  34871. * @returns the requested parser or null
  34872. */
  34873. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34874. /**
  34875. * Parser json data and populate both a scene and its associated container object
  34876. * @param jsonData Defines the data to parse
  34877. * @param scene Defines the scene to parse the data for
  34878. * @param container Defines the container attached to the parsing sequence
  34879. * @param rootUrl Defines the root url of the data
  34880. */
  34881. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34882. /**
  34883. * Gets the list of root nodes (ie. nodes with no parent)
  34884. */
  34885. rootNodes: Node[];
  34886. /** All of the cameras added to this scene
  34887. * @see http://doc.babylonjs.com/babylon101/cameras
  34888. */
  34889. cameras: Camera[];
  34890. /**
  34891. * All of the lights added to this scene
  34892. * @see http://doc.babylonjs.com/babylon101/lights
  34893. */
  34894. lights: Light[];
  34895. /**
  34896. * All of the (abstract) meshes added to this scene
  34897. */
  34898. meshes: AbstractMesh[];
  34899. /**
  34900. * The list of skeletons added to the scene
  34901. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34902. */
  34903. skeletons: Skeleton[];
  34904. /**
  34905. * All of the particle systems added to this scene
  34906. * @see http://doc.babylonjs.com/babylon101/particles
  34907. */
  34908. particleSystems: IParticleSystem[];
  34909. /**
  34910. * Gets a list of Animations associated with the scene
  34911. */
  34912. animations: Animation[];
  34913. /**
  34914. * All of the animation groups added to this scene
  34915. * @see http://doc.babylonjs.com/how_to/group
  34916. */
  34917. animationGroups: AnimationGroup[];
  34918. /**
  34919. * All of the multi-materials added to this scene
  34920. * @see http://doc.babylonjs.com/how_to/multi_materials
  34921. */
  34922. multiMaterials: MultiMaterial[];
  34923. /**
  34924. * All of the materials added to this scene
  34925. * In the context of a Scene, it is not supposed to be modified manually.
  34926. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34927. * Note also that the order of the Material wihin the array is not significant and might change.
  34928. * @see http://doc.babylonjs.com/babylon101/materials
  34929. */
  34930. materials: Material[];
  34931. /**
  34932. * The list of morph target managers added to the scene
  34933. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34934. */
  34935. morphTargetManagers: MorphTargetManager[];
  34936. /**
  34937. * The list of geometries used in the scene.
  34938. */
  34939. geometries: Geometry[];
  34940. /**
  34941. * All of the tranform nodes added to this scene
  34942. * In the context of a Scene, it is not supposed to be modified manually.
  34943. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34944. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34945. * @see http://doc.babylonjs.com/how_to/transformnode
  34946. */
  34947. transformNodes: TransformNode[];
  34948. /**
  34949. * ActionManagers available on the scene.
  34950. */
  34951. actionManagers: AbstractActionManager[];
  34952. /**
  34953. * Textures to keep.
  34954. */
  34955. textures: BaseTexture[];
  34956. /**
  34957. * Environment texture for the scene
  34958. */
  34959. environmentTexture: Nullable<BaseTexture>;
  34960. }
  34961. }
  34962. declare module BABYLON {
  34963. /**
  34964. * Interface used to define options for Sound class
  34965. */
  34966. export interface ISoundOptions {
  34967. /**
  34968. * Does the sound autoplay once loaded.
  34969. */
  34970. autoplay?: boolean;
  34971. /**
  34972. * Does the sound loop after it finishes playing once.
  34973. */
  34974. loop?: boolean;
  34975. /**
  34976. * Sound's volume
  34977. */
  34978. volume?: number;
  34979. /**
  34980. * Is it a spatial sound?
  34981. */
  34982. spatialSound?: boolean;
  34983. /**
  34984. * Maximum distance to hear that sound
  34985. */
  34986. maxDistance?: number;
  34987. /**
  34988. * Uses user defined attenuation function
  34989. */
  34990. useCustomAttenuation?: boolean;
  34991. /**
  34992. * Define the roll off factor of spatial sounds.
  34993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34994. */
  34995. rolloffFactor?: number;
  34996. /**
  34997. * Define the reference distance the sound should be heard perfectly.
  34998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34999. */
  35000. refDistance?: number;
  35001. /**
  35002. * Define the distance attenuation model the sound will follow.
  35003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35004. */
  35005. distanceModel?: string;
  35006. /**
  35007. * Defines the playback speed (1 by default)
  35008. */
  35009. playbackRate?: number;
  35010. /**
  35011. * Defines if the sound is from a streaming source
  35012. */
  35013. streaming?: boolean;
  35014. /**
  35015. * Defines an optional length (in seconds) inside the sound file
  35016. */
  35017. length?: number;
  35018. /**
  35019. * Defines an optional offset (in seconds) inside the sound file
  35020. */
  35021. offset?: number;
  35022. /**
  35023. * If true, URLs will not be required to state the audio file codec to use.
  35024. */
  35025. skipCodecCheck?: boolean;
  35026. }
  35027. /**
  35028. * Defines a sound that can be played in the application.
  35029. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35031. */
  35032. export class Sound {
  35033. /**
  35034. * The name of the sound in the scene.
  35035. */
  35036. name: string;
  35037. /**
  35038. * Does the sound autoplay once loaded.
  35039. */
  35040. autoplay: boolean;
  35041. /**
  35042. * Does the sound loop after it finishes playing once.
  35043. */
  35044. loop: boolean;
  35045. /**
  35046. * Does the sound use a custom attenuation curve to simulate the falloff
  35047. * happening when the source gets further away from the camera.
  35048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35049. */
  35050. useCustomAttenuation: boolean;
  35051. /**
  35052. * The sound track id this sound belongs to.
  35053. */
  35054. soundTrackId: number;
  35055. /**
  35056. * Is this sound currently played.
  35057. */
  35058. isPlaying: boolean;
  35059. /**
  35060. * Is this sound currently paused.
  35061. */
  35062. isPaused: boolean;
  35063. /**
  35064. * Does this sound enables spatial sound.
  35065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35066. */
  35067. spatialSound: boolean;
  35068. /**
  35069. * Define the reference distance the sound should be heard perfectly.
  35070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35071. */
  35072. refDistance: number;
  35073. /**
  35074. * Define the roll off factor of spatial sounds.
  35075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35076. */
  35077. rolloffFactor: number;
  35078. /**
  35079. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35081. */
  35082. maxDistance: number;
  35083. /**
  35084. * Define the distance attenuation model the sound will follow.
  35085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35086. */
  35087. distanceModel: string;
  35088. /**
  35089. * @hidden
  35090. * Back Compat
  35091. **/
  35092. onended: () => any;
  35093. /**
  35094. * Observable event when the current playing sound finishes.
  35095. */
  35096. onEndedObservable: Observable<Sound>;
  35097. private _panningModel;
  35098. private _playbackRate;
  35099. private _streaming;
  35100. private _startTime;
  35101. private _startOffset;
  35102. private _position;
  35103. /** @hidden */
  35104. _positionInEmitterSpace: boolean;
  35105. private _localDirection;
  35106. private _volume;
  35107. private _isReadyToPlay;
  35108. private _isDirectional;
  35109. private _readyToPlayCallback;
  35110. private _audioBuffer;
  35111. private _soundSource;
  35112. private _streamingSource;
  35113. private _soundPanner;
  35114. private _soundGain;
  35115. private _inputAudioNode;
  35116. private _outputAudioNode;
  35117. private _coneInnerAngle;
  35118. private _coneOuterAngle;
  35119. private _coneOuterGain;
  35120. private _scene;
  35121. private _connectedTransformNode;
  35122. private _customAttenuationFunction;
  35123. private _registerFunc;
  35124. private _isOutputConnected;
  35125. private _htmlAudioElement;
  35126. private _urlType;
  35127. private _length?;
  35128. private _offset?;
  35129. /** @hidden */
  35130. static _SceneComponentInitialization: (scene: Scene) => void;
  35131. /**
  35132. * Create a sound and attach it to a scene
  35133. * @param name Name of your sound
  35134. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35135. * @param scene defines the scene the sound belongs to
  35136. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35137. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35138. */
  35139. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35140. /**
  35141. * Release the sound and its associated resources
  35142. */
  35143. dispose(): void;
  35144. /**
  35145. * Gets if the sounds is ready to be played or not.
  35146. * @returns true if ready, otherwise false
  35147. */
  35148. isReady(): boolean;
  35149. private _soundLoaded;
  35150. /**
  35151. * Sets the data of the sound from an audiobuffer
  35152. * @param audioBuffer The audioBuffer containing the data
  35153. */
  35154. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35155. /**
  35156. * Updates the current sounds options such as maxdistance, loop...
  35157. * @param options A JSON object containing values named as the object properties
  35158. */
  35159. updateOptions(options: ISoundOptions): void;
  35160. private _createSpatialParameters;
  35161. private _updateSpatialParameters;
  35162. /**
  35163. * Switch the panning model to HRTF:
  35164. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35166. */
  35167. switchPanningModelToHRTF(): void;
  35168. /**
  35169. * Switch the panning model to Equal Power:
  35170. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35172. */
  35173. switchPanningModelToEqualPower(): void;
  35174. private _switchPanningModel;
  35175. /**
  35176. * Connect this sound to a sound track audio node like gain...
  35177. * @param soundTrackAudioNode the sound track audio node to connect to
  35178. */
  35179. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35180. /**
  35181. * Transform this sound into a directional source
  35182. * @param coneInnerAngle Size of the inner cone in degree
  35183. * @param coneOuterAngle Size of the outer cone in degree
  35184. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35185. */
  35186. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35187. /**
  35188. * Gets or sets the inner angle for the directional cone.
  35189. */
  35190. /**
  35191. * Gets or sets the inner angle for the directional cone.
  35192. */
  35193. directionalConeInnerAngle: number;
  35194. /**
  35195. * Gets or sets the outer angle for the directional cone.
  35196. */
  35197. /**
  35198. * Gets or sets the outer angle for the directional cone.
  35199. */
  35200. directionalConeOuterAngle: number;
  35201. /**
  35202. * Sets the position of the emitter if spatial sound is enabled
  35203. * @param newPosition Defines the new posisiton
  35204. */
  35205. setPosition(newPosition: Vector3): void;
  35206. /**
  35207. * Sets the local direction of the emitter if spatial sound is enabled
  35208. * @param newLocalDirection Defines the new local direction
  35209. */
  35210. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35211. private _updateDirection;
  35212. /** @hidden */
  35213. updateDistanceFromListener(): void;
  35214. /**
  35215. * Sets a new custom attenuation function for the sound.
  35216. * @param callback Defines the function used for the attenuation
  35217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35218. */
  35219. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35220. /**
  35221. * Play the sound
  35222. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35223. * @param offset (optional) Start the sound at a specific time in seconds
  35224. * @param length (optional) Sound duration (in seconds)
  35225. */
  35226. play(time?: number, offset?: number, length?: number): void;
  35227. private _onended;
  35228. /**
  35229. * Stop the sound
  35230. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35231. */
  35232. stop(time?: number): void;
  35233. /**
  35234. * Put the sound in pause
  35235. */
  35236. pause(): void;
  35237. /**
  35238. * Sets a dedicated volume for this sounds
  35239. * @param newVolume Define the new volume of the sound
  35240. * @param time Define time for gradual change to new volume
  35241. */
  35242. setVolume(newVolume: number, time?: number): void;
  35243. /**
  35244. * Set the sound play back rate
  35245. * @param newPlaybackRate Define the playback rate the sound should be played at
  35246. */
  35247. setPlaybackRate(newPlaybackRate: number): void;
  35248. /**
  35249. * Gets the volume of the sound.
  35250. * @returns the volume of the sound
  35251. */
  35252. getVolume(): number;
  35253. /**
  35254. * Attach the sound to a dedicated mesh
  35255. * @param transformNode The transform node to connect the sound with
  35256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35257. */
  35258. attachToMesh(transformNode: TransformNode): void;
  35259. /**
  35260. * Detach the sound from the previously attached mesh
  35261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35262. */
  35263. detachFromMesh(): void;
  35264. private _onRegisterAfterWorldMatrixUpdate;
  35265. /**
  35266. * Clone the current sound in the scene.
  35267. * @returns the new sound clone
  35268. */
  35269. clone(): Nullable<Sound>;
  35270. /**
  35271. * Gets the current underlying audio buffer containing the data
  35272. * @returns the audio buffer
  35273. */
  35274. getAudioBuffer(): Nullable<AudioBuffer>;
  35275. /**
  35276. * Serializes the Sound in a JSON representation
  35277. * @returns the JSON representation of the sound
  35278. */
  35279. serialize(): any;
  35280. /**
  35281. * Parse a JSON representation of a sound to innstantiate in a given scene
  35282. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35283. * @param scene Define the scene the new parsed sound should be created in
  35284. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35285. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35286. * @returns the newly parsed sound
  35287. */
  35288. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35289. }
  35290. }
  35291. declare module BABYLON {
  35292. /**
  35293. * This defines an action helpful to play a defined sound on a triggered action.
  35294. */
  35295. export class PlaySoundAction extends Action {
  35296. private _sound;
  35297. /**
  35298. * Instantiate the action
  35299. * @param triggerOptions defines the trigger options
  35300. * @param sound defines the sound to play
  35301. * @param condition defines the trigger related conditions
  35302. */
  35303. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35304. /** @hidden */
  35305. _prepare(): void;
  35306. /**
  35307. * Execute the action and play the sound.
  35308. */
  35309. execute(): void;
  35310. /**
  35311. * Serializes the actions and its related information.
  35312. * @param parent defines the object to serialize in
  35313. * @returns the serialized object
  35314. */
  35315. serialize(parent: any): any;
  35316. }
  35317. /**
  35318. * This defines an action helpful to stop a defined sound on a triggered action.
  35319. */
  35320. export class StopSoundAction extends Action {
  35321. private _sound;
  35322. /**
  35323. * Instantiate the action
  35324. * @param triggerOptions defines the trigger options
  35325. * @param sound defines the sound to stop
  35326. * @param condition defines the trigger related conditions
  35327. */
  35328. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35329. /** @hidden */
  35330. _prepare(): void;
  35331. /**
  35332. * Execute the action and stop the sound.
  35333. */
  35334. execute(): void;
  35335. /**
  35336. * Serializes the actions and its related information.
  35337. * @param parent defines the object to serialize in
  35338. * @returns the serialized object
  35339. */
  35340. serialize(parent: any): any;
  35341. }
  35342. }
  35343. declare module BABYLON {
  35344. /**
  35345. * This defines an action responsible to change the value of a property
  35346. * by interpolating between its current value and the newly set one once triggered.
  35347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35348. */
  35349. export class InterpolateValueAction extends Action {
  35350. /**
  35351. * Defines the path of the property where the value should be interpolated
  35352. */
  35353. propertyPath: string;
  35354. /**
  35355. * Defines the target value at the end of the interpolation.
  35356. */
  35357. value: any;
  35358. /**
  35359. * Defines the time it will take for the property to interpolate to the value.
  35360. */
  35361. duration: number;
  35362. /**
  35363. * Defines if the other scene animations should be stopped when the action has been triggered
  35364. */
  35365. stopOtherAnimations?: boolean;
  35366. /**
  35367. * Defines a callback raised once the interpolation animation has been done.
  35368. */
  35369. onInterpolationDone?: () => void;
  35370. /**
  35371. * Observable triggered once the interpolation animation has been done.
  35372. */
  35373. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35374. private _target;
  35375. private _effectiveTarget;
  35376. private _property;
  35377. /**
  35378. * Instantiate the action
  35379. * @param triggerOptions defines the trigger options
  35380. * @param target defines the object containing the value to interpolate
  35381. * @param propertyPath defines the path to the property in the target object
  35382. * @param value defines the target value at the end of the interpolation
  35383. * @param duration deines the time it will take for the property to interpolate to the value.
  35384. * @param condition defines the trigger related conditions
  35385. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35386. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35387. */
  35388. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35389. /** @hidden */
  35390. _prepare(): void;
  35391. /**
  35392. * Execute the action starts the value interpolation.
  35393. */
  35394. execute(): void;
  35395. /**
  35396. * Serializes the actions and its related information.
  35397. * @param parent defines the object to serialize in
  35398. * @returns the serialized object
  35399. */
  35400. serialize(parent: any): any;
  35401. }
  35402. }
  35403. declare module BABYLON {
  35404. /**
  35405. * Options allowed during the creation of a sound track.
  35406. */
  35407. export interface ISoundTrackOptions {
  35408. /**
  35409. * The volume the sound track should take during creation
  35410. */
  35411. volume?: number;
  35412. /**
  35413. * Define if the sound track is the main sound track of the scene
  35414. */
  35415. mainTrack?: boolean;
  35416. }
  35417. /**
  35418. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35419. * It will be also used in a future release to apply effects on a specific track.
  35420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35421. */
  35422. export class SoundTrack {
  35423. /**
  35424. * The unique identifier of the sound track in the scene.
  35425. */
  35426. id: number;
  35427. /**
  35428. * The list of sounds included in the sound track.
  35429. */
  35430. soundCollection: Array<Sound>;
  35431. private _outputAudioNode;
  35432. private _scene;
  35433. private _isMainTrack;
  35434. private _connectedAnalyser;
  35435. private _options;
  35436. private _isInitialized;
  35437. /**
  35438. * Creates a new sound track.
  35439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35440. * @param scene Define the scene the sound track belongs to
  35441. * @param options
  35442. */
  35443. constructor(scene: Scene, options?: ISoundTrackOptions);
  35444. private _initializeSoundTrackAudioGraph;
  35445. /**
  35446. * Release the sound track and its associated resources
  35447. */
  35448. dispose(): void;
  35449. /**
  35450. * Adds a sound to this sound track
  35451. * @param sound define the cound to add
  35452. * @ignoreNaming
  35453. */
  35454. AddSound(sound: Sound): void;
  35455. /**
  35456. * Removes a sound to this sound track
  35457. * @param sound define the cound to remove
  35458. * @ignoreNaming
  35459. */
  35460. RemoveSound(sound: Sound): void;
  35461. /**
  35462. * Set a global volume for the full sound track.
  35463. * @param newVolume Define the new volume of the sound track
  35464. */
  35465. setVolume(newVolume: number): void;
  35466. /**
  35467. * Switch the panning model to HRTF:
  35468. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35470. */
  35471. switchPanningModelToHRTF(): void;
  35472. /**
  35473. * Switch the panning model to Equal Power:
  35474. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35476. */
  35477. switchPanningModelToEqualPower(): void;
  35478. /**
  35479. * Connect the sound track to an audio analyser allowing some amazing
  35480. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35482. * @param analyser The analyser to connect to the engine
  35483. */
  35484. connectToAnalyser(analyser: Analyser): void;
  35485. }
  35486. }
  35487. declare module BABYLON {
  35488. interface AbstractScene {
  35489. /**
  35490. * The list of sounds used in the scene.
  35491. */
  35492. sounds: Nullable<Array<Sound>>;
  35493. }
  35494. interface Scene {
  35495. /**
  35496. * @hidden
  35497. * Backing field
  35498. */
  35499. _mainSoundTrack: SoundTrack;
  35500. /**
  35501. * The main sound track played by the scene.
  35502. * It cotains your primary collection of sounds.
  35503. */
  35504. mainSoundTrack: SoundTrack;
  35505. /**
  35506. * The list of sound tracks added to the scene
  35507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35508. */
  35509. soundTracks: Nullable<Array<SoundTrack>>;
  35510. /**
  35511. * Gets a sound using a given name
  35512. * @param name defines the name to search for
  35513. * @return the found sound or null if not found at all.
  35514. */
  35515. getSoundByName(name: string): Nullable<Sound>;
  35516. /**
  35517. * Gets or sets if audio support is enabled
  35518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35519. */
  35520. audioEnabled: boolean;
  35521. /**
  35522. * Gets or sets if audio will be output to headphones
  35523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35524. */
  35525. headphone: boolean;
  35526. /**
  35527. * Gets or sets custom audio listener position provider
  35528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35529. */
  35530. audioListenerPositionProvider: Nullable<() => Vector3>;
  35531. }
  35532. /**
  35533. * Defines the sound scene component responsible to manage any sounds
  35534. * in a given scene.
  35535. */
  35536. export class AudioSceneComponent implements ISceneSerializableComponent {
  35537. /**
  35538. * The component name helpfull to identify the component in the list of scene components.
  35539. */
  35540. readonly name: string;
  35541. /**
  35542. * The scene the component belongs to.
  35543. */
  35544. scene: Scene;
  35545. private _audioEnabled;
  35546. /**
  35547. * Gets whether audio is enabled or not.
  35548. * Please use related enable/disable method to switch state.
  35549. */
  35550. readonly audioEnabled: boolean;
  35551. private _headphone;
  35552. /**
  35553. * Gets whether audio is outputing to headphone or not.
  35554. * Please use the according Switch methods to change output.
  35555. */
  35556. readonly headphone: boolean;
  35557. private _audioListenerPositionProvider;
  35558. /**
  35559. * Gets the current audio listener position provider
  35560. */
  35561. /**
  35562. * Sets a custom listener position for all sounds in the scene
  35563. * By default, this is the position of the first active camera
  35564. */
  35565. audioListenerPositionProvider: Nullable<() => Vector3>;
  35566. /**
  35567. * Creates a new instance of the component for the given scene
  35568. * @param scene Defines the scene to register the component in
  35569. */
  35570. constructor(scene: Scene);
  35571. /**
  35572. * Registers the component in a given scene
  35573. */
  35574. register(): void;
  35575. /**
  35576. * Rebuilds the elements related to this component in case of
  35577. * context lost for instance.
  35578. */
  35579. rebuild(): void;
  35580. /**
  35581. * Serializes the component data to the specified json object
  35582. * @param serializationObject The object to serialize to
  35583. */
  35584. serialize(serializationObject: any): void;
  35585. /**
  35586. * Adds all the elements from the container to the scene
  35587. * @param container the container holding the elements
  35588. */
  35589. addFromContainer(container: AbstractScene): void;
  35590. /**
  35591. * Removes all the elements in the container from the scene
  35592. * @param container contains the elements to remove
  35593. * @param dispose if the removed element should be disposed (default: false)
  35594. */
  35595. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35596. /**
  35597. * Disposes the component and the associated ressources.
  35598. */
  35599. dispose(): void;
  35600. /**
  35601. * Disables audio in the associated scene.
  35602. */
  35603. disableAudio(): void;
  35604. /**
  35605. * Enables audio in the associated scene.
  35606. */
  35607. enableAudio(): void;
  35608. /**
  35609. * Switch audio to headphone output.
  35610. */
  35611. switchAudioModeForHeadphones(): void;
  35612. /**
  35613. * Switch audio to normal speakers.
  35614. */
  35615. switchAudioModeForNormalSpeakers(): void;
  35616. private _afterRender;
  35617. }
  35618. }
  35619. declare module BABYLON {
  35620. /**
  35621. * Wraps one or more Sound objects and selects one with random weight for playback.
  35622. */
  35623. export class WeightedSound {
  35624. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35625. loop: boolean;
  35626. private _coneInnerAngle;
  35627. private _coneOuterAngle;
  35628. private _volume;
  35629. /** A Sound is currently playing. */
  35630. isPlaying: boolean;
  35631. /** A Sound is currently paused. */
  35632. isPaused: boolean;
  35633. private _sounds;
  35634. private _weights;
  35635. private _currentIndex?;
  35636. /**
  35637. * Creates a new WeightedSound from the list of sounds given.
  35638. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35639. * @param sounds Array of Sounds that will be selected from.
  35640. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35641. */
  35642. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35643. /**
  35644. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35645. */
  35646. /**
  35647. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35648. */
  35649. directionalConeInnerAngle: number;
  35650. /**
  35651. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35652. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35653. */
  35654. /**
  35655. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35656. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35657. */
  35658. directionalConeOuterAngle: number;
  35659. /**
  35660. * Playback volume.
  35661. */
  35662. /**
  35663. * Playback volume.
  35664. */
  35665. volume: number;
  35666. private _onended;
  35667. /**
  35668. * Suspend playback
  35669. */
  35670. pause(): void;
  35671. /**
  35672. * Stop playback
  35673. */
  35674. stop(): void;
  35675. /**
  35676. * Start playback.
  35677. * @param startOffset Position the clip head at a specific time in seconds.
  35678. */
  35679. play(startOffset?: number): void;
  35680. }
  35681. }
  35682. declare module BABYLON {
  35683. /**
  35684. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35685. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35686. */
  35687. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35688. /**
  35689. * Gets the name of the behavior.
  35690. */
  35691. readonly name: string;
  35692. /**
  35693. * The easing function used by animations
  35694. */
  35695. static EasingFunction: BackEase;
  35696. /**
  35697. * The easing mode used by animations
  35698. */
  35699. static EasingMode: number;
  35700. /**
  35701. * The duration of the animation, in milliseconds
  35702. */
  35703. transitionDuration: number;
  35704. /**
  35705. * Length of the distance animated by the transition when lower radius is reached
  35706. */
  35707. lowerRadiusTransitionRange: number;
  35708. /**
  35709. * Length of the distance animated by the transition when upper radius is reached
  35710. */
  35711. upperRadiusTransitionRange: number;
  35712. private _autoTransitionRange;
  35713. /**
  35714. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35715. */
  35716. /**
  35717. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35718. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35719. */
  35720. autoTransitionRange: boolean;
  35721. private _attachedCamera;
  35722. private _onAfterCheckInputsObserver;
  35723. private _onMeshTargetChangedObserver;
  35724. /**
  35725. * Initializes the behavior.
  35726. */
  35727. init(): void;
  35728. /**
  35729. * Attaches the behavior to its arc rotate camera.
  35730. * @param camera Defines the camera to attach the behavior to
  35731. */
  35732. attach(camera: ArcRotateCamera): void;
  35733. /**
  35734. * Detaches the behavior from its current arc rotate camera.
  35735. */
  35736. detach(): void;
  35737. private _radiusIsAnimating;
  35738. private _radiusBounceTransition;
  35739. private _animatables;
  35740. private _cachedWheelPrecision;
  35741. /**
  35742. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35743. * @param radiusLimit The limit to check against.
  35744. * @return Bool to indicate if at limit.
  35745. */
  35746. private _isRadiusAtLimit;
  35747. /**
  35748. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35749. * @param radiusDelta The delta by which to animate to. Can be negative.
  35750. */
  35751. private _applyBoundRadiusAnimation;
  35752. /**
  35753. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35754. */
  35755. protected _clearAnimationLocks(): void;
  35756. /**
  35757. * Stops and removes all animations that have been applied to the camera
  35758. */
  35759. stopAllAnimations(): void;
  35760. }
  35761. }
  35762. declare module BABYLON {
  35763. /**
  35764. * 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.
  35765. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35766. */
  35767. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35768. /**
  35769. * Gets the name of the behavior.
  35770. */
  35771. readonly name: string;
  35772. private _mode;
  35773. private _radiusScale;
  35774. private _positionScale;
  35775. private _defaultElevation;
  35776. private _elevationReturnTime;
  35777. private _elevationReturnWaitTime;
  35778. private _zoomStopsAnimation;
  35779. private _framingTime;
  35780. /**
  35781. * The easing function used by animations
  35782. */
  35783. static EasingFunction: ExponentialEase;
  35784. /**
  35785. * The easing mode used by animations
  35786. */
  35787. static EasingMode: number;
  35788. /**
  35789. * Sets the current mode used by the behavior
  35790. */
  35791. /**
  35792. * Gets current mode used by the behavior.
  35793. */
  35794. mode: number;
  35795. /**
  35796. * Sets the scale applied to the radius (1 by default)
  35797. */
  35798. /**
  35799. * Gets the scale applied to the radius
  35800. */
  35801. radiusScale: number;
  35802. /**
  35803. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35804. */
  35805. /**
  35806. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35807. */
  35808. positionScale: number;
  35809. /**
  35810. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35811. * behaviour is triggered, in radians.
  35812. */
  35813. /**
  35814. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35815. * behaviour is triggered, in radians.
  35816. */
  35817. defaultElevation: number;
  35818. /**
  35819. * Sets the time (in milliseconds) taken to return to the default beta position.
  35820. * Negative value indicates camera should not return to default.
  35821. */
  35822. /**
  35823. * Gets the time (in milliseconds) taken to return to the default beta position.
  35824. * Negative value indicates camera should not return to default.
  35825. */
  35826. elevationReturnTime: number;
  35827. /**
  35828. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35829. */
  35830. /**
  35831. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35832. */
  35833. elevationReturnWaitTime: number;
  35834. /**
  35835. * Sets the flag that indicates if user zooming should stop animation.
  35836. */
  35837. /**
  35838. * Gets the flag that indicates if user zooming should stop animation.
  35839. */
  35840. zoomStopsAnimation: boolean;
  35841. /**
  35842. * Sets the transition time when framing the mesh, in milliseconds
  35843. */
  35844. /**
  35845. * Gets the transition time when framing the mesh, in milliseconds
  35846. */
  35847. framingTime: number;
  35848. /**
  35849. * Define if the behavior should automatically change the configured
  35850. * camera limits and sensibilities.
  35851. */
  35852. autoCorrectCameraLimitsAndSensibility: boolean;
  35853. private _onPrePointerObservableObserver;
  35854. private _onAfterCheckInputsObserver;
  35855. private _onMeshTargetChangedObserver;
  35856. private _attachedCamera;
  35857. private _isPointerDown;
  35858. private _lastInteractionTime;
  35859. /**
  35860. * Initializes the behavior.
  35861. */
  35862. init(): void;
  35863. /**
  35864. * Attaches the behavior to its arc rotate camera.
  35865. * @param camera Defines the camera to attach the behavior to
  35866. */
  35867. attach(camera: ArcRotateCamera): void;
  35868. /**
  35869. * Detaches the behavior from its current arc rotate camera.
  35870. */
  35871. detach(): void;
  35872. private _animatables;
  35873. private _betaIsAnimating;
  35874. private _betaTransition;
  35875. private _radiusTransition;
  35876. private _vectorTransition;
  35877. /**
  35878. * Targets the given mesh and updates zoom level accordingly.
  35879. * @param mesh The mesh to target.
  35880. * @param radius Optional. If a cached radius position already exists, overrides default.
  35881. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35882. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35883. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35884. */
  35885. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35886. /**
  35887. * Targets the given mesh with its children and updates zoom level accordingly.
  35888. * @param mesh The mesh to target.
  35889. * @param radius Optional. If a cached radius position already exists, overrides default.
  35890. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35891. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35892. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35893. */
  35894. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35895. /**
  35896. * Targets the given meshes with their children and updates zoom level accordingly.
  35897. * @param meshes The mesh to target.
  35898. * @param radius Optional. If a cached radius position already exists, overrides default.
  35899. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35900. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35901. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35902. */
  35903. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35904. /**
  35905. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35906. * @param minimumWorld Determines the smaller position of the bounding box extend
  35907. * @param maximumWorld Determines the bigger position of the bounding box extend
  35908. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35909. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35910. */
  35911. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35912. /**
  35913. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35914. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35915. * frustum width.
  35916. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35917. * to fully enclose the mesh in the viewing frustum.
  35918. */
  35919. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35920. /**
  35921. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35922. * is automatically returned to its default position (expected to be above ground plane).
  35923. */
  35924. private _maintainCameraAboveGround;
  35925. /**
  35926. * Returns the frustum slope based on the canvas ratio and camera FOV
  35927. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35928. */
  35929. private _getFrustumSlope;
  35930. /**
  35931. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35932. */
  35933. private _clearAnimationLocks;
  35934. /**
  35935. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35936. */
  35937. private _applyUserInteraction;
  35938. /**
  35939. * Stops and removes all animations that have been applied to the camera
  35940. */
  35941. stopAllAnimations(): void;
  35942. /**
  35943. * Gets a value indicating if the user is moving the camera
  35944. */
  35945. readonly isUserIsMoving: boolean;
  35946. /**
  35947. * The camera can move all the way towards the mesh.
  35948. */
  35949. static IgnoreBoundsSizeMode: number;
  35950. /**
  35951. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35952. */
  35953. static FitFrustumSidesMode: number;
  35954. }
  35955. }
  35956. declare module BABYLON {
  35957. /**
  35958. * Base class for Camera Pointer Inputs.
  35959. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35960. * for example usage.
  35961. */
  35962. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35963. /**
  35964. * Defines the camera the input is attached to.
  35965. */
  35966. abstract camera: Camera;
  35967. /**
  35968. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35969. */
  35970. protected _altKey: boolean;
  35971. protected _ctrlKey: boolean;
  35972. protected _metaKey: boolean;
  35973. protected _shiftKey: boolean;
  35974. /**
  35975. * Which mouse buttons were pressed at time of last mouse event.
  35976. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35977. */
  35978. protected _buttonsPressed: number;
  35979. /**
  35980. * Defines the buttons associated with the input to handle camera move.
  35981. */
  35982. buttons: number[];
  35983. /**
  35984. * Attach the input controls to a specific dom element to get the input from.
  35985. * @param element Defines the element the controls should be listened from
  35986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35987. */
  35988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35989. /**
  35990. * Detach the current controls from the specified dom element.
  35991. * @param element Defines the element to stop listening the inputs from
  35992. */
  35993. detachControl(element: Nullable<HTMLElement>): void;
  35994. /**
  35995. * Gets the class name of the current input.
  35996. * @returns the class name
  35997. */
  35998. getClassName(): string;
  35999. /**
  36000. * Get the friendly name associated with the input class.
  36001. * @returns the input friendly name
  36002. */
  36003. getSimpleName(): string;
  36004. /**
  36005. * Called on pointer POINTERDOUBLETAP event.
  36006. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36007. */
  36008. protected onDoubleTap(type: string): void;
  36009. /**
  36010. * Called on pointer POINTERMOVE event if only a single touch is active.
  36011. * Override this method to provide functionality.
  36012. */
  36013. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36014. /**
  36015. * Called on pointer POINTERMOVE event if multiple touches are active.
  36016. * Override this method to provide functionality.
  36017. */
  36018. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36019. /**
  36020. * Called on JS contextmenu event.
  36021. * Override this method to provide functionality.
  36022. */
  36023. protected onContextMenu(evt: PointerEvent): void;
  36024. /**
  36025. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36026. * press.
  36027. * Override this method to provide functionality.
  36028. */
  36029. protected onButtonDown(evt: PointerEvent): void;
  36030. /**
  36031. * Called each time a new POINTERUP event occurs. Ie, for each button
  36032. * release.
  36033. * Override this method to provide functionality.
  36034. */
  36035. protected onButtonUp(evt: PointerEvent): void;
  36036. /**
  36037. * Called when window becomes inactive.
  36038. * Override this method to provide functionality.
  36039. */
  36040. protected onLostFocus(): void;
  36041. private _pointerInput;
  36042. private _observer;
  36043. private _onLostFocus;
  36044. private pointA;
  36045. private pointB;
  36046. }
  36047. }
  36048. declare module BABYLON {
  36049. /**
  36050. * Manage the pointers inputs to control an arc rotate camera.
  36051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36052. */
  36053. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36054. /**
  36055. * Defines the camera the input is attached to.
  36056. */
  36057. camera: ArcRotateCamera;
  36058. /**
  36059. * Gets the class name of the current input.
  36060. * @returns the class name
  36061. */
  36062. getClassName(): string;
  36063. /**
  36064. * Defines the buttons associated with the input to handle camera move.
  36065. */
  36066. buttons: number[];
  36067. /**
  36068. * Defines the pointer angular sensibility along the X axis or how fast is
  36069. * the camera rotating.
  36070. */
  36071. angularSensibilityX: number;
  36072. /**
  36073. * Defines the pointer angular sensibility along the Y axis or how fast is
  36074. * the camera rotating.
  36075. */
  36076. angularSensibilityY: number;
  36077. /**
  36078. * Defines the pointer pinch precision or how fast is the camera zooming.
  36079. */
  36080. pinchPrecision: number;
  36081. /**
  36082. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36083. * from 0.
  36084. * It defines the percentage of current camera.radius to use as delta when
  36085. * pinch zoom is used.
  36086. */
  36087. pinchDeltaPercentage: number;
  36088. /**
  36089. * Defines the pointer panning sensibility or how fast is the camera moving.
  36090. */
  36091. panningSensibility: number;
  36092. /**
  36093. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36094. */
  36095. multiTouchPanning: boolean;
  36096. /**
  36097. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36098. * zoom (pinch) through multitouch.
  36099. */
  36100. multiTouchPanAndZoom: boolean;
  36101. /**
  36102. * Revers pinch action direction.
  36103. */
  36104. pinchInwards: boolean;
  36105. private _isPanClick;
  36106. private _twoFingerActivityCount;
  36107. private _isPinching;
  36108. /**
  36109. * Called on pointer POINTERMOVE event if only a single touch is active.
  36110. */
  36111. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36112. /**
  36113. * Called on pointer POINTERDOUBLETAP event.
  36114. */
  36115. protected onDoubleTap(type: string): void;
  36116. /**
  36117. * Called on pointer POINTERMOVE event if multiple touches are active.
  36118. */
  36119. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36120. /**
  36121. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36122. * press.
  36123. */
  36124. protected onButtonDown(evt: PointerEvent): void;
  36125. /**
  36126. * Called each time a new POINTERUP event occurs. Ie, for each button
  36127. * release.
  36128. */
  36129. protected onButtonUp(evt: PointerEvent): void;
  36130. /**
  36131. * Called when window becomes inactive.
  36132. */
  36133. protected onLostFocus(): void;
  36134. }
  36135. }
  36136. declare module BABYLON {
  36137. /**
  36138. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36140. */
  36141. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36142. /**
  36143. * Defines the camera the input is attached to.
  36144. */
  36145. camera: ArcRotateCamera;
  36146. /**
  36147. * Defines the list of key codes associated with the up action (increase alpha)
  36148. */
  36149. keysUp: number[];
  36150. /**
  36151. * Defines the list of key codes associated with the down action (decrease alpha)
  36152. */
  36153. keysDown: number[];
  36154. /**
  36155. * Defines the list of key codes associated with the left action (increase beta)
  36156. */
  36157. keysLeft: number[];
  36158. /**
  36159. * Defines the list of key codes associated with the right action (decrease beta)
  36160. */
  36161. keysRight: number[];
  36162. /**
  36163. * Defines the list of key codes associated with the reset action.
  36164. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36165. */
  36166. keysReset: number[];
  36167. /**
  36168. * Defines the panning sensibility of the inputs.
  36169. * (How fast is the camera paning)
  36170. */
  36171. panningSensibility: number;
  36172. /**
  36173. * Defines the zooming sensibility of the inputs.
  36174. * (How fast is the camera zooming)
  36175. */
  36176. zoomingSensibility: number;
  36177. /**
  36178. * Defines wether maintaining the alt key down switch the movement mode from
  36179. * orientation to zoom.
  36180. */
  36181. useAltToZoom: boolean;
  36182. /**
  36183. * Rotation speed of the camera
  36184. */
  36185. angularSpeed: number;
  36186. private _keys;
  36187. private _ctrlPressed;
  36188. private _altPressed;
  36189. private _onCanvasBlurObserver;
  36190. private _onKeyboardObserver;
  36191. private _engine;
  36192. private _scene;
  36193. /**
  36194. * Attach the input controls to a specific dom element to get the input from.
  36195. * @param element Defines the element the controls should be listened from
  36196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36197. */
  36198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36199. /**
  36200. * Detach the current controls from the specified dom element.
  36201. * @param element Defines the element to stop listening the inputs from
  36202. */
  36203. detachControl(element: Nullable<HTMLElement>): void;
  36204. /**
  36205. * Update the current camera state depending on the inputs that have been used this frame.
  36206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36207. */
  36208. checkInputs(): void;
  36209. /**
  36210. * Gets the class name of the current intput.
  36211. * @returns the class name
  36212. */
  36213. getClassName(): string;
  36214. /**
  36215. * Get the friendly name associated with the input class.
  36216. * @returns the input friendly name
  36217. */
  36218. getSimpleName(): string;
  36219. }
  36220. }
  36221. declare module BABYLON {
  36222. /**
  36223. * Manage the mouse wheel inputs to control an arc rotate camera.
  36224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36225. */
  36226. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36227. /**
  36228. * Defines the camera the input is attached to.
  36229. */
  36230. camera: ArcRotateCamera;
  36231. /**
  36232. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36233. */
  36234. wheelPrecision: number;
  36235. /**
  36236. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36237. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36238. */
  36239. wheelDeltaPercentage: number;
  36240. private _wheel;
  36241. private _observer;
  36242. private computeDeltaFromMouseWheelLegacyEvent;
  36243. /**
  36244. * Attach the input controls to a specific dom element to get the input from.
  36245. * @param element Defines the element the controls should be listened from
  36246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36247. */
  36248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36249. /**
  36250. * Detach the current controls from the specified dom element.
  36251. * @param element Defines the element to stop listening the inputs from
  36252. */
  36253. detachControl(element: Nullable<HTMLElement>): void;
  36254. /**
  36255. * Gets the class name of the current intput.
  36256. * @returns the class name
  36257. */
  36258. getClassName(): string;
  36259. /**
  36260. * Get the friendly name associated with the input class.
  36261. * @returns the input friendly name
  36262. */
  36263. getSimpleName(): string;
  36264. }
  36265. }
  36266. declare module BABYLON {
  36267. /**
  36268. * Default Inputs manager for the ArcRotateCamera.
  36269. * It groups all the default supported inputs for ease of use.
  36270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36271. */
  36272. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36273. /**
  36274. * Instantiates a new ArcRotateCameraInputsManager.
  36275. * @param camera Defines the camera the inputs belong to
  36276. */
  36277. constructor(camera: ArcRotateCamera);
  36278. /**
  36279. * Add mouse wheel input support to the input manager.
  36280. * @returns the current input manager
  36281. */
  36282. addMouseWheel(): ArcRotateCameraInputsManager;
  36283. /**
  36284. * Add pointers input support to the input manager.
  36285. * @returns the current input manager
  36286. */
  36287. addPointers(): ArcRotateCameraInputsManager;
  36288. /**
  36289. * Add keyboard input support to the input manager.
  36290. * @returns the current input manager
  36291. */
  36292. addKeyboard(): ArcRotateCameraInputsManager;
  36293. }
  36294. }
  36295. declare module BABYLON {
  36296. /**
  36297. * This represents an orbital type of camera.
  36298. *
  36299. * 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.
  36300. * 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.
  36301. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36302. */
  36303. export class ArcRotateCamera extends TargetCamera {
  36304. /**
  36305. * Defines the rotation angle of the camera along the longitudinal axis.
  36306. */
  36307. alpha: number;
  36308. /**
  36309. * Defines the rotation angle of the camera along the latitudinal axis.
  36310. */
  36311. beta: number;
  36312. /**
  36313. * Defines the radius of the camera from it s target point.
  36314. */
  36315. radius: number;
  36316. protected _target: Vector3;
  36317. protected _targetHost: Nullable<AbstractMesh>;
  36318. /**
  36319. * Defines the target point of the camera.
  36320. * The camera looks towards it form the radius distance.
  36321. */
  36322. target: Vector3;
  36323. /**
  36324. * Define the current local position of the camera in the scene
  36325. */
  36326. position: Vector3;
  36327. protected _upVector: Vector3;
  36328. protected _upToYMatrix: Matrix;
  36329. protected _YToUpMatrix: Matrix;
  36330. /**
  36331. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36332. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36333. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36334. */
  36335. upVector: Vector3;
  36336. /**
  36337. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36338. */
  36339. setMatUp(): void;
  36340. /**
  36341. * Current inertia value on the longitudinal axis.
  36342. * The bigger this number the longer it will take for the camera to stop.
  36343. */
  36344. inertialAlphaOffset: number;
  36345. /**
  36346. * Current inertia value on the latitudinal axis.
  36347. * The bigger this number the longer it will take for the camera to stop.
  36348. */
  36349. inertialBetaOffset: number;
  36350. /**
  36351. * Current inertia value on the radius axis.
  36352. * The bigger this number the longer it will take for the camera to stop.
  36353. */
  36354. inertialRadiusOffset: number;
  36355. /**
  36356. * Minimum allowed angle on the longitudinal axis.
  36357. * This can help limiting how the Camera is able to move in the scene.
  36358. */
  36359. lowerAlphaLimit: Nullable<number>;
  36360. /**
  36361. * Maximum allowed angle on the longitudinal axis.
  36362. * This can help limiting how the Camera is able to move in the scene.
  36363. */
  36364. upperAlphaLimit: Nullable<number>;
  36365. /**
  36366. * Minimum allowed angle on the latitudinal axis.
  36367. * This can help limiting how the Camera is able to move in the scene.
  36368. */
  36369. lowerBetaLimit: number;
  36370. /**
  36371. * Maximum allowed angle on the latitudinal axis.
  36372. * This can help limiting how the Camera is able to move in the scene.
  36373. */
  36374. upperBetaLimit: number;
  36375. /**
  36376. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36377. * This can help limiting how the Camera is able to move in the scene.
  36378. */
  36379. lowerRadiusLimit: Nullable<number>;
  36380. /**
  36381. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36382. * This can help limiting how the Camera is able to move in the scene.
  36383. */
  36384. upperRadiusLimit: Nullable<number>;
  36385. /**
  36386. * Defines the current inertia value used during panning of the camera along the X axis.
  36387. */
  36388. inertialPanningX: number;
  36389. /**
  36390. * Defines the current inertia value used during panning of the camera along the Y axis.
  36391. */
  36392. inertialPanningY: number;
  36393. /**
  36394. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36395. * Basically if your fingers moves away from more than this distance you will be considered
  36396. * in pinch mode.
  36397. */
  36398. pinchToPanMaxDistance: number;
  36399. /**
  36400. * Defines the maximum distance the camera can pan.
  36401. * This could help keeping the cammera always in your scene.
  36402. */
  36403. panningDistanceLimit: Nullable<number>;
  36404. /**
  36405. * Defines the target of the camera before paning.
  36406. */
  36407. panningOriginTarget: Vector3;
  36408. /**
  36409. * Defines the value of the inertia used during panning.
  36410. * 0 would mean stop inertia and one would mean no decelleration at all.
  36411. */
  36412. panningInertia: number;
  36413. /**
  36414. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36415. */
  36416. angularSensibilityX: number;
  36417. /**
  36418. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36419. */
  36420. angularSensibilityY: number;
  36421. /**
  36422. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36423. */
  36424. pinchPrecision: number;
  36425. /**
  36426. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36427. * It will be used instead of pinchDeltaPrecision if different from 0.
  36428. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36429. */
  36430. pinchDeltaPercentage: number;
  36431. /**
  36432. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36433. */
  36434. panningSensibility: number;
  36435. /**
  36436. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36437. */
  36438. keysUp: number[];
  36439. /**
  36440. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36441. */
  36442. keysDown: number[];
  36443. /**
  36444. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36445. */
  36446. keysLeft: number[];
  36447. /**
  36448. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36449. */
  36450. keysRight: number[];
  36451. /**
  36452. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36453. */
  36454. wheelPrecision: number;
  36455. /**
  36456. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36457. * It will be used instead of pinchDeltaPrecision if different from 0.
  36458. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36459. */
  36460. wheelDeltaPercentage: number;
  36461. /**
  36462. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36463. */
  36464. zoomOnFactor: number;
  36465. /**
  36466. * Defines a screen offset for the camera position.
  36467. */
  36468. targetScreenOffset: Vector2;
  36469. /**
  36470. * Allows the camera to be completely reversed.
  36471. * If false the camera can not arrive upside down.
  36472. */
  36473. allowUpsideDown: boolean;
  36474. /**
  36475. * Define if double tap/click is used to restore the previously saved state of the camera.
  36476. */
  36477. useInputToRestoreState: boolean;
  36478. /** @hidden */
  36479. _viewMatrix: Matrix;
  36480. /** @hidden */
  36481. _useCtrlForPanning: boolean;
  36482. /** @hidden */
  36483. _panningMouseButton: number;
  36484. /**
  36485. * Defines the input associated to the camera.
  36486. */
  36487. inputs: ArcRotateCameraInputsManager;
  36488. /** @hidden */
  36489. _reset: () => void;
  36490. /**
  36491. * Defines the allowed panning axis.
  36492. */
  36493. panningAxis: Vector3;
  36494. protected _localDirection: Vector3;
  36495. protected _transformedDirection: Vector3;
  36496. private _bouncingBehavior;
  36497. /**
  36498. * Gets the bouncing behavior of the camera if it has been enabled.
  36499. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36500. */
  36501. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36502. /**
  36503. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36505. */
  36506. useBouncingBehavior: boolean;
  36507. private _framingBehavior;
  36508. /**
  36509. * Gets the framing behavior of the camera if it has been enabled.
  36510. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36511. */
  36512. readonly framingBehavior: Nullable<FramingBehavior>;
  36513. /**
  36514. * Defines if the framing behavior of the camera is enabled on the camera.
  36515. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36516. */
  36517. useFramingBehavior: boolean;
  36518. private _autoRotationBehavior;
  36519. /**
  36520. * Gets the auto rotation behavior of the camera if it has been enabled.
  36521. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36522. */
  36523. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36524. /**
  36525. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36526. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36527. */
  36528. useAutoRotationBehavior: boolean;
  36529. /**
  36530. * Observable triggered when the mesh target has been changed on the camera.
  36531. */
  36532. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36533. /**
  36534. * Event raised when the camera is colliding with a mesh.
  36535. */
  36536. onCollide: (collidedMesh: AbstractMesh) => void;
  36537. /**
  36538. * Defines whether the camera should check collision with the objects oh the scene.
  36539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36540. */
  36541. checkCollisions: boolean;
  36542. /**
  36543. * Defines the collision radius of the camera.
  36544. * This simulates a sphere around the camera.
  36545. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36546. */
  36547. collisionRadius: Vector3;
  36548. protected _collider: Collider;
  36549. protected _previousPosition: Vector3;
  36550. protected _collisionVelocity: Vector3;
  36551. protected _newPosition: Vector3;
  36552. protected _previousAlpha: number;
  36553. protected _previousBeta: number;
  36554. protected _previousRadius: number;
  36555. protected _collisionTriggered: boolean;
  36556. protected _targetBoundingCenter: Nullable<Vector3>;
  36557. private _computationVector;
  36558. /**
  36559. * Instantiates a new ArcRotateCamera in a given scene
  36560. * @param name Defines the name of the camera
  36561. * @param alpha Defines the camera rotation along the logitudinal axis
  36562. * @param beta Defines the camera rotation along the latitudinal axis
  36563. * @param radius Defines the camera distance from its target
  36564. * @param target Defines the camera target
  36565. * @param scene Defines the scene the camera belongs to
  36566. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36567. */
  36568. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36569. /** @hidden */
  36570. _initCache(): void;
  36571. /** @hidden */
  36572. _updateCache(ignoreParentClass?: boolean): void;
  36573. protected _getTargetPosition(): Vector3;
  36574. private _storedAlpha;
  36575. private _storedBeta;
  36576. private _storedRadius;
  36577. private _storedTarget;
  36578. private _storedTargetScreenOffset;
  36579. /**
  36580. * Stores the current state of the camera (alpha, beta, radius and target)
  36581. * @returns the camera itself
  36582. */
  36583. storeState(): Camera;
  36584. /**
  36585. * @hidden
  36586. * Restored camera state. You must call storeState() first
  36587. */
  36588. _restoreStateValues(): boolean;
  36589. /** @hidden */
  36590. _isSynchronizedViewMatrix(): boolean;
  36591. /**
  36592. * Attached controls to the current camera.
  36593. * @param element Defines the element the controls should be listened from
  36594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36595. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36596. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36597. */
  36598. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36599. /**
  36600. * Detach the current controls from the camera.
  36601. * The camera will stop reacting to inputs.
  36602. * @param element Defines the element to stop listening the inputs from
  36603. */
  36604. detachControl(element: HTMLElement): void;
  36605. /** @hidden */
  36606. _checkInputs(): void;
  36607. protected _checkLimits(): void;
  36608. /**
  36609. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36610. */
  36611. rebuildAnglesAndRadius(): void;
  36612. /**
  36613. * Use a position to define the current camera related information like aplha, beta and radius
  36614. * @param position Defines the position to set the camera at
  36615. */
  36616. setPosition(position: Vector3): void;
  36617. /**
  36618. * Defines the target the camera should look at.
  36619. * This will automatically adapt alpha beta and radius to fit within the new target.
  36620. * @param target Defines the new target as a Vector or a mesh
  36621. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36622. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36623. */
  36624. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36625. /** @hidden */
  36626. _getViewMatrix(): Matrix;
  36627. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36628. /**
  36629. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36630. * @param meshes Defines the mesh to zoom on
  36631. * @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)
  36632. */
  36633. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36634. /**
  36635. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36636. * The target will be changed but the radius
  36637. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36638. * @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)
  36639. */
  36640. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36641. min: Vector3;
  36642. max: Vector3;
  36643. distance: number;
  36644. }, doNotUpdateMaxZ?: boolean): void;
  36645. /**
  36646. * @override
  36647. * Override Camera.createRigCamera
  36648. */
  36649. createRigCamera(name: string, cameraIndex: number): Camera;
  36650. /**
  36651. * @hidden
  36652. * @override
  36653. * Override Camera._updateRigCameras
  36654. */
  36655. _updateRigCameras(): void;
  36656. /**
  36657. * Destroy the camera and release the current resources hold by it.
  36658. */
  36659. dispose(): void;
  36660. /**
  36661. * Gets the current object class name.
  36662. * @return the class name
  36663. */
  36664. getClassName(): string;
  36665. }
  36666. }
  36667. declare module BABYLON {
  36668. /**
  36669. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36670. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36671. */
  36672. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36673. /**
  36674. * Gets the name of the behavior.
  36675. */
  36676. readonly name: string;
  36677. private _zoomStopsAnimation;
  36678. private _idleRotationSpeed;
  36679. private _idleRotationWaitTime;
  36680. private _idleRotationSpinupTime;
  36681. /**
  36682. * Sets the flag that indicates if user zooming should stop animation.
  36683. */
  36684. /**
  36685. * Gets the flag that indicates if user zooming should stop animation.
  36686. */
  36687. zoomStopsAnimation: boolean;
  36688. /**
  36689. * Sets the default speed at which the camera rotates around the model.
  36690. */
  36691. /**
  36692. * Gets the default speed at which the camera rotates around the model.
  36693. */
  36694. idleRotationSpeed: number;
  36695. /**
  36696. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36697. */
  36698. /**
  36699. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36700. */
  36701. idleRotationWaitTime: number;
  36702. /**
  36703. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36704. */
  36705. /**
  36706. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36707. */
  36708. idleRotationSpinupTime: number;
  36709. /**
  36710. * Gets a value indicating if the camera is currently rotating because of this behavior
  36711. */
  36712. readonly rotationInProgress: boolean;
  36713. private _onPrePointerObservableObserver;
  36714. private _onAfterCheckInputsObserver;
  36715. private _attachedCamera;
  36716. private _isPointerDown;
  36717. private _lastFrameTime;
  36718. private _lastInteractionTime;
  36719. private _cameraRotationSpeed;
  36720. /**
  36721. * Initializes the behavior.
  36722. */
  36723. init(): void;
  36724. /**
  36725. * Attaches the behavior to its arc rotate camera.
  36726. * @param camera Defines the camera to attach the behavior to
  36727. */
  36728. attach(camera: ArcRotateCamera): void;
  36729. /**
  36730. * Detaches the behavior from its current arc rotate camera.
  36731. */
  36732. detach(): void;
  36733. /**
  36734. * Returns true if user is scrolling.
  36735. * @return true if user is scrolling.
  36736. */
  36737. private _userIsZooming;
  36738. private _lastFrameRadius;
  36739. private _shouldAnimationStopForInteraction;
  36740. /**
  36741. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36742. */
  36743. private _applyUserInteraction;
  36744. private _userIsMoving;
  36745. }
  36746. }
  36747. declare module BABYLON {
  36748. /**
  36749. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36750. */
  36751. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36752. private ui;
  36753. /**
  36754. * The name of the behavior
  36755. */
  36756. name: string;
  36757. /**
  36758. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36759. */
  36760. distanceAwayFromFace: number;
  36761. /**
  36762. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36763. */
  36764. distanceAwayFromBottomOfFace: number;
  36765. private _faceVectors;
  36766. private _target;
  36767. private _scene;
  36768. private _onRenderObserver;
  36769. private _tmpMatrix;
  36770. private _tmpVector;
  36771. /**
  36772. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36773. * @param ui The transform node that should be attched to the mesh
  36774. */
  36775. constructor(ui: TransformNode);
  36776. /**
  36777. * Initializes the behavior
  36778. */
  36779. init(): void;
  36780. private _closestFace;
  36781. private _zeroVector;
  36782. private _lookAtTmpMatrix;
  36783. private _lookAtToRef;
  36784. /**
  36785. * Attaches the AttachToBoxBehavior to the passed in mesh
  36786. * @param target The mesh that the specified node will be attached to
  36787. */
  36788. attach(target: Mesh): void;
  36789. /**
  36790. * Detaches the behavior from the mesh
  36791. */
  36792. detach(): void;
  36793. }
  36794. }
  36795. declare module BABYLON {
  36796. /**
  36797. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36798. */
  36799. export class FadeInOutBehavior implements Behavior<Mesh> {
  36800. /**
  36801. * Time in milliseconds to delay before fading in (Default: 0)
  36802. */
  36803. delay: number;
  36804. /**
  36805. * Time in milliseconds for the mesh to fade in (Default: 300)
  36806. */
  36807. fadeInTime: number;
  36808. private _millisecondsPerFrame;
  36809. private _hovered;
  36810. private _hoverValue;
  36811. private _ownerNode;
  36812. /**
  36813. * Instatiates the FadeInOutBehavior
  36814. */
  36815. constructor();
  36816. /**
  36817. * The name of the behavior
  36818. */
  36819. readonly name: string;
  36820. /**
  36821. * Initializes the behavior
  36822. */
  36823. init(): void;
  36824. /**
  36825. * Attaches the fade behavior on the passed in mesh
  36826. * @param ownerNode The mesh that will be faded in/out once attached
  36827. */
  36828. attach(ownerNode: Mesh): void;
  36829. /**
  36830. * Detaches the behavior from the mesh
  36831. */
  36832. detach(): void;
  36833. /**
  36834. * Triggers the mesh to begin fading in or out
  36835. * @param value if the object should fade in or out (true to fade in)
  36836. */
  36837. fadeIn(value: boolean): void;
  36838. private _update;
  36839. private _setAllVisibility;
  36840. }
  36841. }
  36842. declare module BABYLON {
  36843. /**
  36844. * Class containing a set of static utilities functions for managing Pivots
  36845. * @hidden
  36846. */
  36847. export class PivotTools {
  36848. private static _PivotCached;
  36849. private static _OldPivotPoint;
  36850. private static _PivotTranslation;
  36851. private static _PivotTmpVector;
  36852. /** @hidden */
  36853. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36854. /** @hidden */
  36855. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36856. }
  36857. }
  36858. declare module BABYLON {
  36859. /**
  36860. * Class containing static functions to help procedurally build meshes
  36861. */
  36862. export class PlaneBuilder {
  36863. /**
  36864. * Creates a plane mesh
  36865. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36866. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36867. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36869. * * 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
  36870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36871. * @param name defines the name of the mesh
  36872. * @param options defines the options used to create the mesh
  36873. * @param scene defines the hosting scene
  36874. * @returns the plane mesh
  36875. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36876. */
  36877. static CreatePlane(name: string, options: {
  36878. size?: number;
  36879. width?: number;
  36880. height?: number;
  36881. sideOrientation?: number;
  36882. frontUVs?: Vector4;
  36883. backUVs?: Vector4;
  36884. updatable?: boolean;
  36885. sourcePlane?: Plane;
  36886. }, scene?: Nullable<Scene>): Mesh;
  36887. }
  36888. }
  36889. declare module BABYLON {
  36890. /**
  36891. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36892. */
  36893. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36894. private static _AnyMouseID;
  36895. /**
  36896. * Abstract mesh the behavior is set on
  36897. */
  36898. attachedNode: AbstractMesh;
  36899. private _dragPlane;
  36900. private _scene;
  36901. private _pointerObserver;
  36902. private _beforeRenderObserver;
  36903. private static _planeScene;
  36904. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36905. /**
  36906. * 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)
  36907. */
  36908. maxDragAngle: number;
  36909. /**
  36910. * @hidden
  36911. */
  36912. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36913. /**
  36914. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36915. */
  36916. currentDraggingPointerID: number;
  36917. /**
  36918. * The last position where the pointer hit the drag plane in world space
  36919. */
  36920. lastDragPosition: Vector3;
  36921. /**
  36922. * If the behavior is currently in a dragging state
  36923. */
  36924. dragging: boolean;
  36925. /**
  36926. * 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)
  36927. */
  36928. dragDeltaRatio: number;
  36929. /**
  36930. * If the drag plane orientation should be updated during the dragging (Default: true)
  36931. */
  36932. updateDragPlane: boolean;
  36933. private _debugMode;
  36934. private _moving;
  36935. /**
  36936. * Fires each time the attached mesh is dragged with the pointer
  36937. * * delta between last drag position and current drag position in world space
  36938. * * dragDistance along the drag axis
  36939. * * dragPlaneNormal normal of the current drag plane used during the drag
  36940. * * dragPlanePoint in world space where the drag intersects the drag plane
  36941. */
  36942. onDragObservable: Observable<{
  36943. delta: Vector3;
  36944. dragPlanePoint: Vector3;
  36945. dragPlaneNormal: Vector3;
  36946. dragDistance: number;
  36947. pointerId: number;
  36948. }>;
  36949. /**
  36950. * Fires each time a drag begins (eg. mouse down on mesh)
  36951. */
  36952. onDragStartObservable: Observable<{
  36953. dragPlanePoint: Vector3;
  36954. pointerId: number;
  36955. }>;
  36956. /**
  36957. * Fires each time a drag ends (eg. mouse release after drag)
  36958. */
  36959. onDragEndObservable: Observable<{
  36960. dragPlanePoint: Vector3;
  36961. pointerId: number;
  36962. }>;
  36963. /**
  36964. * If the attached mesh should be moved when dragged
  36965. */
  36966. moveAttached: boolean;
  36967. /**
  36968. * If the drag behavior will react to drag events (Default: true)
  36969. */
  36970. enabled: boolean;
  36971. /**
  36972. * If pointer events should start and release the drag (Default: true)
  36973. */
  36974. startAndReleaseDragOnPointerEvents: boolean;
  36975. /**
  36976. * If camera controls should be detached during the drag
  36977. */
  36978. detachCameraControls: boolean;
  36979. /**
  36980. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36981. */
  36982. useObjectOrienationForDragging: boolean;
  36983. private _options;
  36984. /**
  36985. * Creates a pointer drag behavior that can be attached to a mesh
  36986. * @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)
  36987. */
  36988. constructor(options?: {
  36989. dragAxis?: Vector3;
  36990. dragPlaneNormal?: Vector3;
  36991. });
  36992. /**
  36993. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36994. */
  36995. validateDrag: (targetPosition: Vector3) => boolean;
  36996. /**
  36997. * The name of the behavior
  36998. */
  36999. readonly name: string;
  37000. /**
  37001. * Initializes the behavior
  37002. */
  37003. init(): void;
  37004. private _tmpVector;
  37005. private _alternatePickedPoint;
  37006. private _worldDragAxis;
  37007. private _targetPosition;
  37008. private _attachedElement;
  37009. /**
  37010. * Attaches the drag behavior the passed in mesh
  37011. * @param ownerNode The mesh that will be dragged around once attached
  37012. * @param predicate Predicate to use for pick filtering
  37013. */
  37014. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37015. /**
  37016. * Force relase the drag action by code.
  37017. */
  37018. releaseDrag(): void;
  37019. private _startDragRay;
  37020. private _lastPointerRay;
  37021. /**
  37022. * Simulates the start of a pointer drag event on the behavior
  37023. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37024. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37025. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37026. */
  37027. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37028. private _startDrag;
  37029. private _dragDelta;
  37030. private _moveDrag;
  37031. private _pickWithRayOnDragPlane;
  37032. private _pointA;
  37033. private _pointB;
  37034. private _pointC;
  37035. private _lineA;
  37036. private _lineB;
  37037. private _localAxis;
  37038. private _lookAt;
  37039. private _updateDragPlanePosition;
  37040. /**
  37041. * Detaches the behavior from the mesh
  37042. */
  37043. detach(): void;
  37044. }
  37045. }
  37046. declare module BABYLON {
  37047. /**
  37048. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37049. */
  37050. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37051. private _dragBehaviorA;
  37052. private _dragBehaviorB;
  37053. private _startDistance;
  37054. private _initialScale;
  37055. private _targetScale;
  37056. private _ownerNode;
  37057. private _sceneRenderObserver;
  37058. /**
  37059. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37060. */
  37061. constructor();
  37062. /**
  37063. * The name of the behavior
  37064. */
  37065. readonly name: string;
  37066. /**
  37067. * Initializes the behavior
  37068. */
  37069. init(): void;
  37070. private _getCurrentDistance;
  37071. /**
  37072. * Attaches the scale behavior the passed in mesh
  37073. * @param ownerNode The mesh that will be scaled around once attached
  37074. */
  37075. attach(ownerNode: Mesh): void;
  37076. /**
  37077. * Detaches the behavior from the mesh
  37078. */
  37079. detach(): void;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. /**
  37084. * 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
  37085. */
  37086. export class SixDofDragBehavior implements Behavior<Mesh> {
  37087. private static _virtualScene;
  37088. private _ownerNode;
  37089. private _sceneRenderObserver;
  37090. private _scene;
  37091. private _targetPosition;
  37092. private _virtualOriginMesh;
  37093. private _virtualDragMesh;
  37094. private _pointerObserver;
  37095. private _moving;
  37096. private _startingOrientation;
  37097. /**
  37098. * 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)
  37099. */
  37100. private zDragFactor;
  37101. /**
  37102. * If the object should rotate to face the drag origin
  37103. */
  37104. rotateDraggedObject: boolean;
  37105. /**
  37106. * If the behavior is currently in a dragging state
  37107. */
  37108. dragging: boolean;
  37109. /**
  37110. * 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)
  37111. */
  37112. dragDeltaRatio: number;
  37113. /**
  37114. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37115. */
  37116. currentDraggingPointerID: number;
  37117. /**
  37118. * If camera controls should be detached during the drag
  37119. */
  37120. detachCameraControls: boolean;
  37121. /**
  37122. * Fires each time a drag starts
  37123. */
  37124. onDragStartObservable: Observable<{}>;
  37125. /**
  37126. * Fires each time a drag ends (eg. mouse release after drag)
  37127. */
  37128. onDragEndObservable: Observable<{}>;
  37129. /**
  37130. * 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
  37131. */
  37132. constructor();
  37133. /**
  37134. * The name of the behavior
  37135. */
  37136. readonly name: string;
  37137. /**
  37138. * Initializes the behavior
  37139. */
  37140. init(): void;
  37141. /**
  37142. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37143. */
  37144. private readonly _pointerCamera;
  37145. /**
  37146. * Attaches the scale behavior the passed in mesh
  37147. * @param ownerNode The mesh that will be scaled around once attached
  37148. */
  37149. attach(ownerNode: Mesh): void;
  37150. /**
  37151. * Detaches the behavior from the mesh
  37152. */
  37153. detach(): void;
  37154. }
  37155. }
  37156. declare module BABYLON {
  37157. /**
  37158. * Class used to apply inverse kinematics to bones
  37159. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37160. */
  37161. export class BoneIKController {
  37162. private static _tmpVecs;
  37163. private static _tmpQuat;
  37164. private static _tmpMats;
  37165. /**
  37166. * Gets or sets the target mesh
  37167. */
  37168. targetMesh: AbstractMesh;
  37169. /** Gets or sets the mesh used as pole */
  37170. poleTargetMesh: AbstractMesh;
  37171. /**
  37172. * Gets or sets the bone used as pole
  37173. */
  37174. poleTargetBone: Nullable<Bone>;
  37175. /**
  37176. * Gets or sets the target position
  37177. */
  37178. targetPosition: Vector3;
  37179. /**
  37180. * Gets or sets the pole target position
  37181. */
  37182. poleTargetPosition: Vector3;
  37183. /**
  37184. * Gets or sets the pole target local offset
  37185. */
  37186. poleTargetLocalOffset: Vector3;
  37187. /**
  37188. * Gets or sets the pole angle
  37189. */
  37190. poleAngle: number;
  37191. /**
  37192. * Gets or sets the mesh associated with the controller
  37193. */
  37194. mesh: AbstractMesh;
  37195. /**
  37196. * 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)
  37197. */
  37198. slerpAmount: number;
  37199. private _bone1Quat;
  37200. private _bone1Mat;
  37201. private _bone2Ang;
  37202. private _bone1;
  37203. private _bone2;
  37204. private _bone1Length;
  37205. private _bone2Length;
  37206. private _maxAngle;
  37207. private _maxReach;
  37208. private _rightHandedSystem;
  37209. private _bendAxis;
  37210. private _slerping;
  37211. private _adjustRoll;
  37212. /**
  37213. * Gets or sets maximum allowed angle
  37214. */
  37215. maxAngle: number;
  37216. /**
  37217. * Creates a new BoneIKController
  37218. * @param mesh defines the mesh to control
  37219. * @param bone defines the bone to control
  37220. * @param options defines options to set up the controller
  37221. */
  37222. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37223. targetMesh?: AbstractMesh;
  37224. poleTargetMesh?: AbstractMesh;
  37225. poleTargetBone?: Bone;
  37226. poleTargetLocalOffset?: Vector3;
  37227. poleAngle?: number;
  37228. bendAxis?: Vector3;
  37229. maxAngle?: number;
  37230. slerpAmount?: number;
  37231. });
  37232. private _setMaxAngle;
  37233. /**
  37234. * Force the controller to update the bones
  37235. */
  37236. update(): void;
  37237. }
  37238. }
  37239. declare module BABYLON {
  37240. /**
  37241. * Class used to make a bone look toward a point in space
  37242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37243. */
  37244. export class BoneLookController {
  37245. private static _tmpVecs;
  37246. private static _tmpQuat;
  37247. private static _tmpMats;
  37248. /**
  37249. * The target Vector3 that the bone will look at
  37250. */
  37251. target: Vector3;
  37252. /**
  37253. * The mesh that the bone is attached to
  37254. */
  37255. mesh: AbstractMesh;
  37256. /**
  37257. * The bone that will be looking to the target
  37258. */
  37259. bone: Bone;
  37260. /**
  37261. * The up axis of the coordinate system that is used when the bone is rotated
  37262. */
  37263. upAxis: Vector3;
  37264. /**
  37265. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37266. */
  37267. upAxisSpace: Space;
  37268. /**
  37269. * Used to make an adjustment to the yaw of the bone
  37270. */
  37271. adjustYaw: number;
  37272. /**
  37273. * Used to make an adjustment to the pitch of the bone
  37274. */
  37275. adjustPitch: number;
  37276. /**
  37277. * Used to make an adjustment to the roll of the bone
  37278. */
  37279. adjustRoll: number;
  37280. /**
  37281. * 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)
  37282. */
  37283. slerpAmount: number;
  37284. private _minYaw;
  37285. private _maxYaw;
  37286. private _minPitch;
  37287. private _maxPitch;
  37288. private _minYawSin;
  37289. private _minYawCos;
  37290. private _maxYawSin;
  37291. private _maxYawCos;
  37292. private _midYawConstraint;
  37293. private _minPitchTan;
  37294. private _maxPitchTan;
  37295. private _boneQuat;
  37296. private _slerping;
  37297. private _transformYawPitch;
  37298. private _transformYawPitchInv;
  37299. private _firstFrameSkipped;
  37300. private _yawRange;
  37301. private _fowardAxis;
  37302. /**
  37303. * Gets or sets the minimum yaw angle that the bone can look to
  37304. */
  37305. minYaw: number;
  37306. /**
  37307. * Gets or sets the maximum yaw angle that the bone can look to
  37308. */
  37309. maxYaw: number;
  37310. /**
  37311. * Gets or sets the minimum pitch angle that the bone can look to
  37312. */
  37313. minPitch: number;
  37314. /**
  37315. * Gets or sets the maximum pitch angle that the bone can look to
  37316. */
  37317. maxPitch: number;
  37318. /**
  37319. * Create a BoneLookController
  37320. * @param mesh the mesh that the bone belongs to
  37321. * @param bone the bone that will be looking to the target
  37322. * @param target the target Vector3 to look at
  37323. * @param options optional settings:
  37324. * * maxYaw: the maximum angle the bone will yaw to
  37325. * * minYaw: the minimum angle the bone will yaw to
  37326. * * maxPitch: the maximum angle the bone will pitch to
  37327. * * minPitch: the minimum angle the bone will yaw to
  37328. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37329. * * upAxis: the up axis of the coordinate system
  37330. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37331. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37332. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37333. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37334. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37335. * * adjustRoll: used to make an adjustment to the roll of the bone
  37336. **/
  37337. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37338. maxYaw?: number;
  37339. minYaw?: number;
  37340. maxPitch?: number;
  37341. minPitch?: number;
  37342. slerpAmount?: number;
  37343. upAxis?: Vector3;
  37344. upAxisSpace?: Space;
  37345. yawAxis?: Vector3;
  37346. pitchAxis?: Vector3;
  37347. adjustYaw?: number;
  37348. adjustPitch?: number;
  37349. adjustRoll?: number;
  37350. });
  37351. /**
  37352. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37353. */
  37354. update(): void;
  37355. private _getAngleDiff;
  37356. private _getAngleBetween;
  37357. private _isAngleBetween;
  37358. }
  37359. }
  37360. declare module BABYLON {
  37361. /**
  37362. * Manage the gamepad inputs to control an arc rotate camera.
  37363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37364. */
  37365. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37366. /**
  37367. * Defines the camera the input is attached to.
  37368. */
  37369. camera: ArcRotateCamera;
  37370. /**
  37371. * Defines the gamepad the input is gathering event from.
  37372. */
  37373. gamepad: Nullable<Gamepad>;
  37374. /**
  37375. * Defines the gamepad rotation sensiblity.
  37376. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37377. */
  37378. gamepadRotationSensibility: number;
  37379. /**
  37380. * Defines the gamepad move sensiblity.
  37381. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37382. */
  37383. gamepadMoveSensibility: number;
  37384. private _onGamepadConnectedObserver;
  37385. private _onGamepadDisconnectedObserver;
  37386. /**
  37387. * Attach the input controls to a specific dom element to get the input from.
  37388. * @param element Defines the element the controls should be listened from
  37389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37390. */
  37391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37392. /**
  37393. * Detach the current controls from the specified dom element.
  37394. * @param element Defines the element to stop listening the inputs from
  37395. */
  37396. detachControl(element: Nullable<HTMLElement>): void;
  37397. /**
  37398. * Update the current camera state depending on the inputs that have been used this frame.
  37399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37400. */
  37401. checkInputs(): void;
  37402. /**
  37403. * Gets the class name of the current intput.
  37404. * @returns the class name
  37405. */
  37406. getClassName(): string;
  37407. /**
  37408. * Get the friendly name associated with the input class.
  37409. * @returns the input friendly name
  37410. */
  37411. getSimpleName(): string;
  37412. }
  37413. }
  37414. declare module BABYLON {
  37415. interface ArcRotateCameraInputsManager {
  37416. /**
  37417. * Add orientation input support to the input manager.
  37418. * @returns the current input manager
  37419. */
  37420. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37421. }
  37422. /**
  37423. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37425. */
  37426. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37427. /**
  37428. * Defines the camera the input is attached to.
  37429. */
  37430. camera: ArcRotateCamera;
  37431. /**
  37432. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37433. */
  37434. alphaCorrection: number;
  37435. /**
  37436. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37437. */
  37438. gammaCorrection: number;
  37439. private _alpha;
  37440. private _gamma;
  37441. private _dirty;
  37442. private _deviceOrientationHandler;
  37443. /**
  37444. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37445. */
  37446. constructor();
  37447. /**
  37448. * Attach the input controls to a specific dom element to get the input from.
  37449. * @param element Defines the element the controls should be listened from
  37450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37451. */
  37452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37453. /** @hidden */
  37454. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37455. /**
  37456. * Update the current camera state depending on the inputs that have been used this frame.
  37457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37458. */
  37459. checkInputs(): void;
  37460. /**
  37461. * Detach the current controls from the specified dom element.
  37462. * @param element Defines the element to stop listening the inputs from
  37463. */
  37464. detachControl(element: Nullable<HTMLElement>): void;
  37465. /**
  37466. * Gets the class name of the current intput.
  37467. * @returns the class name
  37468. */
  37469. getClassName(): string;
  37470. /**
  37471. * Get the friendly name associated with the input class.
  37472. * @returns the input friendly name
  37473. */
  37474. getSimpleName(): string;
  37475. }
  37476. }
  37477. declare module BABYLON {
  37478. /**
  37479. * Listen to mouse events to control the camera.
  37480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37481. */
  37482. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37483. /**
  37484. * Defines the camera the input is attached to.
  37485. */
  37486. camera: FlyCamera;
  37487. /**
  37488. * Defines if touch is enabled. (Default is true.)
  37489. */
  37490. touchEnabled: boolean;
  37491. /**
  37492. * Defines the buttons associated with the input to handle camera rotation.
  37493. */
  37494. buttons: number[];
  37495. /**
  37496. * Assign buttons for Yaw control.
  37497. */
  37498. buttonsYaw: number[];
  37499. /**
  37500. * Assign buttons for Pitch control.
  37501. */
  37502. buttonsPitch: number[];
  37503. /**
  37504. * Assign buttons for Roll control.
  37505. */
  37506. buttonsRoll: number[];
  37507. /**
  37508. * Detect if any button is being pressed while mouse is moved.
  37509. * -1 = Mouse locked.
  37510. * 0 = Left button.
  37511. * 1 = Middle Button.
  37512. * 2 = Right Button.
  37513. */
  37514. activeButton: number;
  37515. /**
  37516. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37517. * Higher values reduce its sensitivity.
  37518. */
  37519. angularSensibility: number;
  37520. private _mousemoveCallback;
  37521. private _observer;
  37522. private _rollObserver;
  37523. private previousPosition;
  37524. private noPreventDefault;
  37525. private element;
  37526. /**
  37527. * Listen to mouse events to control the camera.
  37528. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37530. */
  37531. constructor(touchEnabled?: boolean);
  37532. /**
  37533. * Attach the mouse control to the HTML DOM element.
  37534. * @param element Defines the element that listens to the input events.
  37535. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37536. */
  37537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37538. /**
  37539. * Detach the current controls from the specified dom element.
  37540. * @param element Defines the element to stop listening the inputs from
  37541. */
  37542. detachControl(element: Nullable<HTMLElement>): void;
  37543. /**
  37544. * Gets the class name of the current input.
  37545. * @returns the class name.
  37546. */
  37547. getClassName(): string;
  37548. /**
  37549. * Get the friendly name associated with the input class.
  37550. * @returns the input's friendly name.
  37551. */
  37552. getSimpleName(): string;
  37553. private _pointerInput;
  37554. private _onMouseMove;
  37555. /**
  37556. * Rotate camera by mouse offset.
  37557. */
  37558. private rotateCamera;
  37559. }
  37560. }
  37561. declare module BABYLON {
  37562. /**
  37563. * Default Inputs manager for the FlyCamera.
  37564. * It groups all the default supported inputs for ease of use.
  37565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37566. */
  37567. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37568. /**
  37569. * Instantiates a new FlyCameraInputsManager.
  37570. * @param camera Defines the camera the inputs belong to.
  37571. */
  37572. constructor(camera: FlyCamera);
  37573. /**
  37574. * Add keyboard input support to the input manager.
  37575. * @returns the new FlyCameraKeyboardMoveInput().
  37576. */
  37577. addKeyboard(): FlyCameraInputsManager;
  37578. /**
  37579. * Add mouse input support to the input manager.
  37580. * @param touchEnabled Enable touch screen support.
  37581. * @returns the new FlyCameraMouseInput().
  37582. */
  37583. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37584. }
  37585. }
  37586. declare module BABYLON {
  37587. /**
  37588. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37589. * such as in a 3D Space Shooter or a Flight Simulator.
  37590. */
  37591. export class FlyCamera extends TargetCamera {
  37592. /**
  37593. * Define the collision ellipsoid of the camera.
  37594. * This is helpful for simulating a camera body, like a player's body.
  37595. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37596. */
  37597. ellipsoid: Vector3;
  37598. /**
  37599. * Define an offset for the position of the ellipsoid around the camera.
  37600. * This can be helpful if the camera is attached away from the player's body center,
  37601. * such as at its head.
  37602. */
  37603. ellipsoidOffset: Vector3;
  37604. /**
  37605. * Enable or disable collisions of the camera with the rest of the scene objects.
  37606. */
  37607. checkCollisions: boolean;
  37608. /**
  37609. * Enable or disable gravity on the camera.
  37610. */
  37611. applyGravity: boolean;
  37612. /**
  37613. * Define the current direction the camera is moving to.
  37614. */
  37615. cameraDirection: Vector3;
  37616. /**
  37617. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37618. * This overrides and empties cameraRotation.
  37619. */
  37620. rotationQuaternion: Quaternion;
  37621. /**
  37622. * Track Roll to maintain the wanted Rolling when looking around.
  37623. */
  37624. _trackRoll: number;
  37625. /**
  37626. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37627. */
  37628. rollCorrect: number;
  37629. /**
  37630. * Mimic a banked turn, Rolling the camera when Yawing.
  37631. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37632. */
  37633. bankedTurn: boolean;
  37634. /**
  37635. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37636. */
  37637. bankedTurnLimit: number;
  37638. /**
  37639. * Value of 0 disables the banked Roll.
  37640. * Value of 1 is equal to the Yaw angle in radians.
  37641. */
  37642. bankedTurnMultiplier: number;
  37643. /**
  37644. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37645. */
  37646. inputs: FlyCameraInputsManager;
  37647. /**
  37648. * Gets the input sensibility for mouse input.
  37649. * Higher values reduce sensitivity.
  37650. */
  37651. /**
  37652. * Sets the input sensibility for a mouse input.
  37653. * Higher values reduce sensitivity.
  37654. */
  37655. angularSensibility: number;
  37656. /**
  37657. * Get the keys for camera movement forward.
  37658. */
  37659. /**
  37660. * Set the keys for camera movement forward.
  37661. */
  37662. keysForward: number[];
  37663. /**
  37664. * Get the keys for camera movement backward.
  37665. */
  37666. keysBackward: number[];
  37667. /**
  37668. * Get the keys for camera movement up.
  37669. */
  37670. /**
  37671. * Set the keys for camera movement up.
  37672. */
  37673. keysUp: number[];
  37674. /**
  37675. * Get the keys for camera movement down.
  37676. */
  37677. /**
  37678. * Set the keys for camera movement down.
  37679. */
  37680. keysDown: number[];
  37681. /**
  37682. * Get the keys for camera movement left.
  37683. */
  37684. /**
  37685. * Set the keys for camera movement left.
  37686. */
  37687. keysLeft: number[];
  37688. /**
  37689. * Set the keys for camera movement right.
  37690. */
  37691. /**
  37692. * Set the keys for camera movement right.
  37693. */
  37694. keysRight: number[];
  37695. /**
  37696. * Event raised when the camera collides with a mesh in the scene.
  37697. */
  37698. onCollide: (collidedMesh: AbstractMesh) => void;
  37699. private _collider;
  37700. private _needMoveForGravity;
  37701. private _oldPosition;
  37702. private _diffPosition;
  37703. private _newPosition;
  37704. /** @hidden */
  37705. _localDirection: Vector3;
  37706. /** @hidden */
  37707. _transformedDirection: Vector3;
  37708. /**
  37709. * Instantiates a FlyCamera.
  37710. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37711. * such as in a 3D Space Shooter or a Flight Simulator.
  37712. * @param name Define the name of the camera in the scene.
  37713. * @param position Define the starting position of the camera in the scene.
  37714. * @param scene Define the scene the camera belongs to.
  37715. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37716. */
  37717. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37718. /**
  37719. * Attach a control to the HTML DOM element.
  37720. * @param element Defines the element that listens to the input events.
  37721. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37722. */
  37723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37724. /**
  37725. * Detach a control from the HTML DOM element.
  37726. * The camera will stop reacting to that input.
  37727. * @param element Defines the element that listens to the input events.
  37728. */
  37729. detachControl(element: HTMLElement): void;
  37730. private _collisionMask;
  37731. /**
  37732. * Get the mask that the camera ignores in collision events.
  37733. */
  37734. /**
  37735. * Set the mask that the camera ignores in collision events.
  37736. */
  37737. collisionMask: number;
  37738. /** @hidden */
  37739. _collideWithWorld(displacement: Vector3): void;
  37740. /** @hidden */
  37741. private _onCollisionPositionChange;
  37742. /** @hidden */
  37743. _checkInputs(): void;
  37744. /** @hidden */
  37745. _decideIfNeedsToMove(): boolean;
  37746. /** @hidden */
  37747. _updatePosition(): void;
  37748. /**
  37749. * Restore the Roll to its target value at the rate specified.
  37750. * @param rate - Higher means slower restoring.
  37751. * @hidden
  37752. */
  37753. restoreRoll(rate: number): void;
  37754. /**
  37755. * Destroy the camera and release the current resources held by it.
  37756. */
  37757. dispose(): void;
  37758. /**
  37759. * Get the current object class name.
  37760. * @returns the class name.
  37761. */
  37762. getClassName(): string;
  37763. }
  37764. }
  37765. declare module BABYLON {
  37766. /**
  37767. * Listen to keyboard events to control the camera.
  37768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37769. */
  37770. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37771. /**
  37772. * Defines the camera the input is attached to.
  37773. */
  37774. camera: FlyCamera;
  37775. /**
  37776. * The list of keyboard keys used to control the forward move of the camera.
  37777. */
  37778. keysForward: number[];
  37779. /**
  37780. * The list of keyboard keys used to control the backward move of the camera.
  37781. */
  37782. keysBackward: number[];
  37783. /**
  37784. * The list of keyboard keys used to control the forward move of the camera.
  37785. */
  37786. keysUp: number[];
  37787. /**
  37788. * The list of keyboard keys used to control the backward move of the camera.
  37789. */
  37790. keysDown: number[];
  37791. /**
  37792. * The list of keyboard keys used to control the right strafe move of the camera.
  37793. */
  37794. keysRight: number[];
  37795. /**
  37796. * The list of keyboard keys used to control the left strafe move of the camera.
  37797. */
  37798. keysLeft: number[];
  37799. private _keys;
  37800. private _onCanvasBlurObserver;
  37801. private _onKeyboardObserver;
  37802. private _engine;
  37803. private _scene;
  37804. /**
  37805. * Attach the input controls to a specific dom element to get the input from.
  37806. * @param element Defines the element the controls should be listened from
  37807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37808. */
  37809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37810. /**
  37811. * Detach the current controls from the specified dom element.
  37812. * @param element Defines the element to stop listening the inputs from
  37813. */
  37814. detachControl(element: Nullable<HTMLElement>): void;
  37815. /**
  37816. * Gets the class name of the current intput.
  37817. * @returns the class name
  37818. */
  37819. getClassName(): string;
  37820. /** @hidden */
  37821. _onLostFocus(e: FocusEvent): void;
  37822. /**
  37823. * Get the friendly name associated with the input class.
  37824. * @returns the input friendly name
  37825. */
  37826. getSimpleName(): string;
  37827. /**
  37828. * Update the current camera state depending on the inputs that have been used this frame.
  37829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37830. */
  37831. checkInputs(): void;
  37832. }
  37833. }
  37834. declare module BABYLON {
  37835. /**
  37836. * Manage the mouse wheel inputs to control a follow camera.
  37837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37838. */
  37839. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37840. /**
  37841. * Defines the camera the input is attached to.
  37842. */
  37843. camera: FollowCamera;
  37844. /**
  37845. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37846. */
  37847. axisControlRadius: boolean;
  37848. /**
  37849. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37850. */
  37851. axisControlHeight: boolean;
  37852. /**
  37853. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37854. */
  37855. axisControlRotation: boolean;
  37856. /**
  37857. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37858. * relation to mouseWheel events.
  37859. */
  37860. wheelPrecision: number;
  37861. /**
  37862. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37863. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37864. */
  37865. wheelDeltaPercentage: number;
  37866. private _wheel;
  37867. private _observer;
  37868. /**
  37869. * Attach the input controls to a specific dom element to get the input from.
  37870. * @param element Defines the element the controls should be listened from
  37871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37872. */
  37873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37874. /**
  37875. * Detach the current controls from the specified dom element.
  37876. * @param element Defines the element to stop listening the inputs from
  37877. */
  37878. detachControl(element: Nullable<HTMLElement>): void;
  37879. /**
  37880. * Gets the class name of the current intput.
  37881. * @returns the class name
  37882. */
  37883. getClassName(): string;
  37884. /**
  37885. * Get the friendly name associated with the input class.
  37886. * @returns the input friendly name
  37887. */
  37888. getSimpleName(): string;
  37889. }
  37890. }
  37891. declare module BABYLON {
  37892. /**
  37893. * Manage the pointers inputs to control an follow camera.
  37894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37895. */
  37896. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37897. /**
  37898. * Defines the camera the input is attached to.
  37899. */
  37900. camera: FollowCamera;
  37901. /**
  37902. * Gets the class name of the current input.
  37903. * @returns the class name
  37904. */
  37905. getClassName(): string;
  37906. /**
  37907. * Defines the pointer angular sensibility along the X axis or how fast is
  37908. * the camera rotating.
  37909. * A negative number will reverse the axis direction.
  37910. */
  37911. angularSensibilityX: number;
  37912. /**
  37913. * Defines the pointer angular sensibility along the Y axis or how fast is
  37914. * the camera rotating.
  37915. * A negative number will reverse the axis direction.
  37916. */
  37917. angularSensibilityY: number;
  37918. /**
  37919. * Defines the pointer pinch precision or how fast is the camera zooming.
  37920. * A negative number will reverse the axis direction.
  37921. */
  37922. pinchPrecision: number;
  37923. /**
  37924. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37925. * from 0.
  37926. * It defines the percentage of current camera.radius to use as delta when
  37927. * pinch zoom is used.
  37928. */
  37929. pinchDeltaPercentage: number;
  37930. /**
  37931. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37932. */
  37933. axisXControlRadius: boolean;
  37934. /**
  37935. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37936. */
  37937. axisXControlHeight: boolean;
  37938. /**
  37939. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37940. */
  37941. axisXControlRotation: boolean;
  37942. /**
  37943. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37944. */
  37945. axisYControlRadius: boolean;
  37946. /**
  37947. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37948. */
  37949. axisYControlHeight: boolean;
  37950. /**
  37951. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37952. */
  37953. axisYControlRotation: boolean;
  37954. /**
  37955. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37956. */
  37957. axisPinchControlRadius: boolean;
  37958. /**
  37959. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37960. */
  37961. axisPinchControlHeight: boolean;
  37962. /**
  37963. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37964. */
  37965. axisPinchControlRotation: boolean;
  37966. /**
  37967. * Log error messages if basic misconfiguration has occurred.
  37968. */
  37969. warningEnable: boolean;
  37970. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37971. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37972. private _warningCounter;
  37973. private _warning;
  37974. }
  37975. }
  37976. declare module BABYLON {
  37977. /**
  37978. * Default Inputs manager for the FollowCamera.
  37979. * It groups all the default supported inputs for ease of use.
  37980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37981. */
  37982. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37983. /**
  37984. * Instantiates a new FollowCameraInputsManager.
  37985. * @param camera Defines the camera the inputs belong to
  37986. */
  37987. constructor(camera: FollowCamera);
  37988. /**
  37989. * Add keyboard input support to the input manager.
  37990. * @returns the current input manager
  37991. */
  37992. addKeyboard(): FollowCameraInputsManager;
  37993. /**
  37994. * Add mouse wheel input support to the input manager.
  37995. * @returns the current input manager
  37996. */
  37997. addMouseWheel(): FollowCameraInputsManager;
  37998. /**
  37999. * Add pointers input support to the input manager.
  38000. * @returns the current input manager
  38001. */
  38002. addPointers(): FollowCameraInputsManager;
  38003. /**
  38004. * Add orientation input support to the input manager.
  38005. * @returns the current input manager
  38006. */
  38007. addVRDeviceOrientation(): FollowCameraInputsManager;
  38008. }
  38009. }
  38010. declare module BABYLON {
  38011. /**
  38012. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38013. * an arc rotate version arcFollowCamera are available.
  38014. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38015. */
  38016. export class FollowCamera extends TargetCamera {
  38017. /**
  38018. * Distance the follow camera should follow an object at
  38019. */
  38020. radius: number;
  38021. /**
  38022. * Minimum allowed distance of the camera to the axis of rotation
  38023. * (The camera can not get closer).
  38024. * This can help limiting how the Camera is able to move in the scene.
  38025. */
  38026. lowerRadiusLimit: Nullable<number>;
  38027. /**
  38028. * Maximum allowed distance of the camera to the axis of rotation
  38029. * (The camera can not get further).
  38030. * This can help limiting how the Camera is able to move in the scene.
  38031. */
  38032. upperRadiusLimit: Nullable<number>;
  38033. /**
  38034. * Define a rotation offset between the camera and the object it follows
  38035. */
  38036. rotationOffset: number;
  38037. /**
  38038. * Minimum allowed angle to camera position relative to target object.
  38039. * This can help limiting how the Camera is able to move in the scene.
  38040. */
  38041. lowerRotationOffsetLimit: Nullable<number>;
  38042. /**
  38043. * Maximum allowed angle to camera position relative to target object.
  38044. * This can help limiting how the Camera is able to move in the scene.
  38045. */
  38046. upperRotationOffsetLimit: Nullable<number>;
  38047. /**
  38048. * Define a height offset between the camera and the object it follows.
  38049. * It can help following an object from the top (like a car chaing a plane)
  38050. */
  38051. heightOffset: number;
  38052. /**
  38053. * Minimum allowed height of camera position relative to target object.
  38054. * This can help limiting how the Camera is able to move in the scene.
  38055. */
  38056. lowerHeightOffsetLimit: Nullable<number>;
  38057. /**
  38058. * Maximum allowed height of camera position relative to target object.
  38059. * This can help limiting how the Camera is able to move in the scene.
  38060. */
  38061. upperHeightOffsetLimit: Nullable<number>;
  38062. /**
  38063. * Define how fast the camera can accelerate to follow it s target.
  38064. */
  38065. cameraAcceleration: number;
  38066. /**
  38067. * Define the speed limit of the camera following an object.
  38068. */
  38069. maxCameraSpeed: number;
  38070. /**
  38071. * Define the target of the camera.
  38072. */
  38073. lockedTarget: Nullable<AbstractMesh>;
  38074. /**
  38075. * Defines the input associated with the camera.
  38076. */
  38077. inputs: FollowCameraInputsManager;
  38078. /**
  38079. * Instantiates the follow camera.
  38080. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38081. * @param name Define the name of the camera in the scene
  38082. * @param position Define the position of the camera
  38083. * @param scene Define the scene the camera belong to
  38084. * @param lockedTarget Define the target of the camera
  38085. */
  38086. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38087. private _follow;
  38088. /**
  38089. * Attached controls to the current camera.
  38090. * @param element Defines the element the controls should be listened from
  38091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38092. */
  38093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38094. /**
  38095. * Detach the current controls from the camera.
  38096. * The camera will stop reacting to inputs.
  38097. * @param element Defines the element to stop listening the inputs from
  38098. */
  38099. detachControl(element: HTMLElement): void;
  38100. /** @hidden */
  38101. _checkInputs(): void;
  38102. private _checkLimits;
  38103. /**
  38104. * Gets the camera class name.
  38105. * @returns the class name
  38106. */
  38107. getClassName(): string;
  38108. }
  38109. /**
  38110. * Arc Rotate version of the follow camera.
  38111. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38112. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38113. */
  38114. export class ArcFollowCamera extends TargetCamera {
  38115. /** The longitudinal angle of the camera */
  38116. alpha: number;
  38117. /** The latitudinal angle of the camera */
  38118. beta: number;
  38119. /** The radius of the camera from its target */
  38120. radius: number;
  38121. /** Define the camera target (the messh it should follow) */
  38122. target: Nullable<AbstractMesh>;
  38123. private _cartesianCoordinates;
  38124. /**
  38125. * Instantiates a new ArcFollowCamera
  38126. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38127. * @param name Define the name of the camera
  38128. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38129. * @param beta Define the rotation angle of the camera around the elevation axis
  38130. * @param radius Define the radius of the camera from its target point
  38131. * @param target Define the target of the camera
  38132. * @param scene Define the scene the camera belongs to
  38133. */
  38134. constructor(name: string,
  38135. /** The longitudinal angle of the camera */
  38136. alpha: number,
  38137. /** The latitudinal angle of the camera */
  38138. beta: number,
  38139. /** The radius of the camera from its target */
  38140. radius: number,
  38141. /** Define the camera target (the messh it should follow) */
  38142. target: Nullable<AbstractMesh>, scene: Scene);
  38143. private _follow;
  38144. /** @hidden */
  38145. _checkInputs(): void;
  38146. /**
  38147. * Returns the class name of the object.
  38148. * It is mostly used internally for serialization purposes.
  38149. */
  38150. getClassName(): string;
  38151. }
  38152. }
  38153. declare module BABYLON {
  38154. /**
  38155. * Manage the keyboard inputs to control the movement of a follow camera.
  38156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38157. */
  38158. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38159. /**
  38160. * Defines the camera the input is attached to.
  38161. */
  38162. camera: FollowCamera;
  38163. /**
  38164. * Defines the list of key codes associated with the up action (increase heightOffset)
  38165. */
  38166. keysHeightOffsetIncr: number[];
  38167. /**
  38168. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38169. */
  38170. keysHeightOffsetDecr: number[];
  38171. /**
  38172. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38173. */
  38174. keysHeightOffsetModifierAlt: boolean;
  38175. /**
  38176. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38177. */
  38178. keysHeightOffsetModifierCtrl: boolean;
  38179. /**
  38180. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38181. */
  38182. keysHeightOffsetModifierShift: boolean;
  38183. /**
  38184. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38185. */
  38186. keysRotationOffsetIncr: number[];
  38187. /**
  38188. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38189. */
  38190. keysRotationOffsetDecr: number[];
  38191. /**
  38192. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38193. */
  38194. keysRotationOffsetModifierAlt: boolean;
  38195. /**
  38196. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38197. */
  38198. keysRotationOffsetModifierCtrl: boolean;
  38199. /**
  38200. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38201. */
  38202. keysRotationOffsetModifierShift: boolean;
  38203. /**
  38204. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38205. */
  38206. keysRadiusIncr: number[];
  38207. /**
  38208. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38209. */
  38210. keysRadiusDecr: number[];
  38211. /**
  38212. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38213. */
  38214. keysRadiusModifierAlt: boolean;
  38215. /**
  38216. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38217. */
  38218. keysRadiusModifierCtrl: boolean;
  38219. /**
  38220. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38221. */
  38222. keysRadiusModifierShift: boolean;
  38223. /**
  38224. * Defines the rate of change of heightOffset.
  38225. */
  38226. heightSensibility: number;
  38227. /**
  38228. * Defines the rate of change of rotationOffset.
  38229. */
  38230. rotationSensibility: number;
  38231. /**
  38232. * Defines the rate of change of radius.
  38233. */
  38234. radiusSensibility: number;
  38235. private _keys;
  38236. private _ctrlPressed;
  38237. private _altPressed;
  38238. private _shiftPressed;
  38239. private _onCanvasBlurObserver;
  38240. private _onKeyboardObserver;
  38241. private _engine;
  38242. private _scene;
  38243. /**
  38244. * Attach the input controls to a specific dom element to get the input from.
  38245. * @param element Defines the element the controls should be listened from
  38246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38247. */
  38248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38249. /**
  38250. * Detach the current controls from the specified dom element.
  38251. * @param element Defines the element to stop listening the inputs from
  38252. */
  38253. detachControl(element: Nullable<HTMLElement>): void;
  38254. /**
  38255. * Update the current camera state depending on the inputs that have been used this frame.
  38256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38257. */
  38258. checkInputs(): void;
  38259. /**
  38260. * Gets the class name of the current input.
  38261. * @returns the class name
  38262. */
  38263. getClassName(): string;
  38264. /**
  38265. * Get the friendly name associated with the input class.
  38266. * @returns the input friendly name
  38267. */
  38268. getSimpleName(): string;
  38269. /**
  38270. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38271. * allow modification of the heightOffset value.
  38272. */
  38273. private _modifierHeightOffset;
  38274. /**
  38275. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38276. * allow modification of the rotationOffset value.
  38277. */
  38278. private _modifierRotationOffset;
  38279. /**
  38280. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38281. * allow modification of the radius value.
  38282. */
  38283. private _modifierRadius;
  38284. }
  38285. }
  38286. declare module BABYLON {
  38287. interface FreeCameraInputsManager {
  38288. /**
  38289. * @hidden
  38290. */
  38291. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38292. /**
  38293. * Add orientation input support to the input manager.
  38294. * @returns the current input manager
  38295. */
  38296. addDeviceOrientation(): FreeCameraInputsManager;
  38297. }
  38298. /**
  38299. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38300. * Screen rotation is taken into account.
  38301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38302. */
  38303. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38304. private _camera;
  38305. private _screenOrientationAngle;
  38306. private _constantTranform;
  38307. private _screenQuaternion;
  38308. private _alpha;
  38309. private _beta;
  38310. private _gamma;
  38311. /**
  38312. * Can be used to detect if a device orientation sensor is availible on a device
  38313. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38314. * @returns a promise that will resolve on orientation change
  38315. */
  38316. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38317. /**
  38318. * @hidden
  38319. */
  38320. _onDeviceOrientationChangedObservable: Observable<void>;
  38321. /**
  38322. * Instantiates a new input
  38323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38324. */
  38325. constructor();
  38326. /**
  38327. * Define the camera controlled by the input.
  38328. */
  38329. camera: FreeCamera;
  38330. /**
  38331. * Attach the input controls to a specific dom element to get the input from.
  38332. * @param element Defines the element the controls should be listened from
  38333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38334. */
  38335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38336. private _orientationChanged;
  38337. private _deviceOrientation;
  38338. /**
  38339. * Detach the current controls from the specified dom element.
  38340. * @param element Defines the element to stop listening the inputs from
  38341. */
  38342. detachControl(element: Nullable<HTMLElement>): void;
  38343. /**
  38344. * Update the current camera state depending on the inputs that have been used this frame.
  38345. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38346. */
  38347. checkInputs(): void;
  38348. /**
  38349. * Gets the class name of the current intput.
  38350. * @returns the class name
  38351. */
  38352. getClassName(): string;
  38353. /**
  38354. * Get the friendly name associated with the input class.
  38355. * @returns the input friendly name
  38356. */
  38357. getSimpleName(): string;
  38358. }
  38359. }
  38360. declare module BABYLON {
  38361. /**
  38362. * Manage the gamepad inputs to control a free camera.
  38363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38364. */
  38365. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38366. /**
  38367. * Define the camera the input is attached to.
  38368. */
  38369. camera: FreeCamera;
  38370. /**
  38371. * Define the Gamepad controlling the input
  38372. */
  38373. gamepad: Nullable<Gamepad>;
  38374. /**
  38375. * Defines the gamepad rotation sensiblity.
  38376. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38377. */
  38378. gamepadAngularSensibility: number;
  38379. /**
  38380. * Defines the gamepad move sensiblity.
  38381. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38382. */
  38383. gamepadMoveSensibility: number;
  38384. private _onGamepadConnectedObserver;
  38385. private _onGamepadDisconnectedObserver;
  38386. private _cameraTransform;
  38387. private _deltaTransform;
  38388. private _vector3;
  38389. private _vector2;
  38390. /**
  38391. * Attach the input controls to a specific dom element to get the input from.
  38392. * @param element Defines the element the controls should be listened from
  38393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38394. */
  38395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38396. /**
  38397. * Detach the current controls from the specified dom element.
  38398. * @param element Defines the element to stop listening the inputs from
  38399. */
  38400. detachControl(element: Nullable<HTMLElement>): void;
  38401. /**
  38402. * Update the current camera state depending on the inputs that have been used this frame.
  38403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38404. */
  38405. checkInputs(): void;
  38406. /**
  38407. * Gets the class name of the current intput.
  38408. * @returns the class name
  38409. */
  38410. getClassName(): string;
  38411. /**
  38412. * Get the friendly name associated with the input class.
  38413. * @returns the input friendly name
  38414. */
  38415. getSimpleName(): string;
  38416. }
  38417. }
  38418. declare module BABYLON {
  38419. /**
  38420. * Defines the potential axis of a Joystick
  38421. */
  38422. export enum JoystickAxis {
  38423. /** X axis */
  38424. X = 0,
  38425. /** Y axis */
  38426. Y = 1,
  38427. /** Z axis */
  38428. Z = 2
  38429. }
  38430. /**
  38431. * Class used to define virtual joystick (used in touch mode)
  38432. */
  38433. export class VirtualJoystick {
  38434. /**
  38435. * Gets or sets a boolean indicating that left and right values must be inverted
  38436. */
  38437. reverseLeftRight: boolean;
  38438. /**
  38439. * Gets or sets a boolean indicating that up and down values must be inverted
  38440. */
  38441. reverseUpDown: boolean;
  38442. /**
  38443. * Gets the offset value for the position (ie. the change of the position value)
  38444. */
  38445. deltaPosition: Vector3;
  38446. /**
  38447. * Gets a boolean indicating if the virtual joystick was pressed
  38448. */
  38449. pressed: boolean;
  38450. /**
  38451. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38452. */
  38453. static Canvas: Nullable<HTMLCanvasElement>;
  38454. private static _globalJoystickIndex;
  38455. private static vjCanvasContext;
  38456. private static vjCanvasWidth;
  38457. private static vjCanvasHeight;
  38458. private static halfWidth;
  38459. private _action;
  38460. private _axisTargetedByLeftAndRight;
  38461. private _axisTargetedByUpAndDown;
  38462. private _joystickSensibility;
  38463. private _inversedSensibility;
  38464. private _joystickPointerID;
  38465. private _joystickColor;
  38466. private _joystickPointerPos;
  38467. private _joystickPreviousPointerPos;
  38468. private _joystickPointerStartPos;
  38469. private _deltaJoystickVector;
  38470. private _leftJoystick;
  38471. private _touches;
  38472. private _onPointerDownHandlerRef;
  38473. private _onPointerMoveHandlerRef;
  38474. private _onPointerUpHandlerRef;
  38475. private _onResize;
  38476. /**
  38477. * Creates a new virtual joystick
  38478. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38479. */
  38480. constructor(leftJoystick?: boolean);
  38481. /**
  38482. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38483. * @param newJoystickSensibility defines the new sensibility
  38484. */
  38485. setJoystickSensibility(newJoystickSensibility: number): void;
  38486. private _onPointerDown;
  38487. private _onPointerMove;
  38488. private _onPointerUp;
  38489. /**
  38490. * Change the color of the virtual joystick
  38491. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38492. */
  38493. setJoystickColor(newColor: string): void;
  38494. /**
  38495. * Defines a callback to call when the joystick is touched
  38496. * @param action defines the callback
  38497. */
  38498. setActionOnTouch(action: () => any): void;
  38499. /**
  38500. * Defines which axis you'd like to control for left & right
  38501. * @param axis defines the axis to use
  38502. */
  38503. setAxisForLeftRight(axis: JoystickAxis): void;
  38504. /**
  38505. * Defines which axis you'd like to control for up & down
  38506. * @param axis defines the axis to use
  38507. */
  38508. setAxisForUpDown(axis: JoystickAxis): void;
  38509. private _drawVirtualJoystick;
  38510. /**
  38511. * Release internal HTML canvas
  38512. */
  38513. releaseCanvas(): void;
  38514. }
  38515. }
  38516. declare module BABYLON {
  38517. interface FreeCameraInputsManager {
  38518. /**
  38519. * Add virtual joystick input support to the input manager.
  38520. * @returns the current input manager
  38521. */
  38522. addVirtualJoystick(): FreeCameraInputsManager;
  38523. }
  38524. /**
  38525. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38527. */
  38528. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38529. /**
  38530. * Defines the camera the input is attached to.
  38531. */
  38532. camera: FreeCamera;
  38533. private _leftjoystick;
  38534. private _rightjoystick;
  38535. /**
  38536. * Gets the left stick of the virtual joystick.
  38537. * @returns The virtual Joystick
  38538. */
  38539. getLeftJoystick(): VirtualJoystick;
  38540. /**
  38541. * Gets the right stick of the virtual joystick.
  38542. * @returns The virtual Joystick
  38543. */
  38544. getRightJoystick(): VirtualJoystick;
  38545. /**
  38546. * Update the current camera state depending on the inputs that have been used this frame.
  38547. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38548. */
  38549. checkInputs(): void;
  38550. /**
  38551. * Attach the input controls to a specific dom element to get the input from.
  38552. * @param element Defines the element the controls should be listened from
  38553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38554. */
  38555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38556. /**
  38557. * Detach the current controls from the specified dom element.
  38558. * @param element Defines the element to stop listening the inputs from
  38559. */
  38560. detachControl(element: Nullable<HTMLElement>): void;
  38561. /**
  38562. * Gets the class name of the current intput.
  38563. * @returns the class name
  38564. */
  38565. getClassName(): string;
  38566. /**
  38567. * Get the friendly name associated with the input class.
  38568. * @returns the input friendly name
  38569. */
  38570. getSimpleName(): string;
  38571. }
  38572. }
  38573. declare module BABYLON {
  38574. /**
  38575. * This represents a FPS type of camera controlled by touch.
  38576. * This is like a universal camera minus the Gamepad controls.
  38577. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38578. */
  38579. export class TouchCamera extends FreeCamera {
  38580. /**
  38581. * Defines the touch sensibility for rotation.
  38582. * The higher the faster.
  38583. */
  38584. touchAngularSensibility: number;
  38585. /**
  38586. * Defines the touch sensibility for move.
  38587. * The higher the faster.
  38588. */
  38589. touchMoveSensibility: number;
  38590. /**
  38591. * Instantiates a new touch camera.
  38592. * This represents a FPS type of camera controlled by touch.
  38593. * This is like a universal camera minus the Gamepad controls.
  38594. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38595. * @param name Define the name of the camera in the scene
  38596. * @param position Define the start position of the camera in the scene
  38597. * @param scene Define the scene the camera belongs to
  38598. */
  38599. constructor(name: string, position: Vector3, scene: Scene);
  38600. /**
  38601. * Gets the current object class name.
  38602. * @return the class name
  38603. */
  38604. getClassName(): string;
  38605. /** @hidden */
  38606. _setupInputs(): void;
  38607. }
  38608. }
  38609. declare module BABYLON {
  38610. /**
  38611. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38612. * being tilted forward or back and left or right.
  38613. */
  38614. export class DeviceOrientationCamera extends FreeCamera {
  38615. private _initialQuaternion;
  38616. private _quaternionCache;
  38617. private _tmpDragQuaternion;
  38618. private _disablePointerInputWhenUsingDeviceOrientation;
  38619. /**
  38620. * Creates a new device orientation camera
  38621. * @param name The name of the camera
  38622. * @param position The start position camera
  38623. * @param scene The scene the camera belongs to
  38624. */
  38625. constructor(name: string, position: Vector3, scene: Scene);
  38626. /**
  38627. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38628. */
  38629. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38630. private _dragFactor;
  38631. /**
  38632. * Enabled turning on the y axis when the orientation sensor is active
  38633. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38634. */
  38635. enableHorizontalDragging(dragFactor?: number): void;
  38636. /**
  38637. * Gets the current instance class name ("DeviceOrientationCamera").
  38638. * This helps avoiding instanceof at run time.
  38639. * @returns the class name
  38640. */
  38641. getClassName(): string;
  38642. /**
  38643. * @hidden
  38644. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38645. */
  38646. _checkInputs(): void;
  38647. /**
  38648. * Reset the camera to its default orientation on the specified axis only.
  38649. * @param axis The axis to reset
  38650. */
  38651. resetToCurrentRotation(axis?: Axis): void;
  38652. }
  38653. }
  38654. declare module BABYLON {
  38655. /**
  38656. * Defines supported buttons for XBox360 compatible gamepads
  38657. */
  38658. export enum Xbox360Button {
  38659. /** A */
  38660. A = 0,
  38661. /** B */
  38662. B = 1,
  38663. /** X */
  38664. X = 2,
  38665. /** Y */
  38666. Y = 3,
  38667. /** Start */
  38668. Start = 4,
  38669. /** Back */
  38670. Back = 5,
  38671. /** Left button */
  38672. LB = 6,
  38673. /** Right button */
  38674. RB = 7,
  38675. /** Left stick */
  38676. LeftStick = 8,
  38677. /** Right stick */
  38678. RightStick = 9
  38679. }
  38680. /** Defines values for XBox360 DPad */
  38681. export enum Xbox360Dpad {
  38682. /** Up */
  38683. Up = 0,
  38684. /** Down */
  38685. Down = 1,
  38686. /** Left */
  38687. Left = 2,
  38688. /** Right */
  38689. Right = 3
  38690. }
  38691. /**
  38692. * Defines a XBox360 gamepad
  38693. */
  38694. export class Xbox360Pad extends Gamepad {
  38695. private _leftTrigger;
  38696. private _rightTrigger;
  38697. private _onlefttriggerchanged;
  38698. private _onrighttriggerchanged;
  38699. private _onbuttondown;
  38700. private _onbuttonup;
  38701. private _ondpaddown;
  38702. private _ondpadup;
  38703. /** Observable raised when a button is pressed */
  38704. onButtonDownObservable: Observable<Xbox360Button>;
  38705. /** Observable raised when a button is released */
  38706. onButtonUpObservable: Observable<Xbox360Button>;
  38707. /** Observable raised when a pad is pressed */
  38708. onPadDownObservable: Observable<Xbox360Dpad>;
  38709. /** Observable raised when a pad is released */
  38710. onPadUpObservable: Observable<Xbox360Dpad>;
  38711. private _buttonA;
  38712. private _buttonB;
  38713. private _buttonX;
  38714. private _buttonY;
  38715. private _buttonBack;
  38716. private _buttonStart;
  38717. private _buttonLB;
  38718. private _buttonRB;
  38719. private _buttonLeftStick;
  38720. private _buttonRightStick;
  38721. private _dPadUp;
  38722. private _dPadDown;
  38723. private _dPadLeft;
  38724. private _dPadRight;
  38725. private _isXboxOnePad;
  38726. /**
  38727. * Creates a new XBox360 gamepad object
  38728. * @param id defines the id of this gamepad
  38729. * @param index defines its index
  38730. * @param gamepad defines the internal HTML gamepad object
  38731. * @param xboxOne defines if it is a XBox One gamepad
  38732. */
  38733. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38734. /**
  38735. * Defines the callback to call when left trigger is pressed
  38736. * @param callback defines the callback to use
  38737. */
  38738. onlefttriggerchanged(callback: (value: number) => void): void;
  38739. /**
  38740. * Defines the callback to call when right trigger is pressed
  38741. * @param callback defines the callback to use
  38742. */
  38743. onrighttriggerchanged(callback: (value: number) => void): void;
  38744. /**
  38745. * Gets the left trigger value
  38746. */
  38747. /**
  38748. * Sets the left trigger value
  38749. */
  38750. leftTrigger: number;
  38751. /**
  38752. * Gets the right trigger value
  38753. */
  38754. /**
  38755. * Sets the right trigger value
  38756. */
  38757. rightTrigger: number;
  38758. /**
  38759. * Defines the callback to call when a button is pressed
  38760. * @param callback defines the callback to use
  38761. */
  38762. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38763. /**
  38764. * Defines the callback to call when a button is released
  38765. * @param callback defines the callback to use
  38766. */
  38767. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38768. /**
  38769. * Defines the callback to call when a pad is pressed
  38770. * @param callback defines the callback to use
  38771. */
  38772. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38773. /**
  38774. * Defines the callback to call when a pad is released
  38775. * @param callback defines the callback to use
  38776. */
  38777. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38778. private _setButtonValue;
  38779. private _setDPadValue;
  38780. /**
  38781. * Gets the value of the `A` button
  38782. */
  38783. /**
  38784. * Sets the value of the `A` button
  38785. */
  38786. buttonA: number;
  38787. /**
  38788. * Gets the value of the `B` button
  38789. */
  38790. /**
  38791. * Sets the value of the `B` button
  38792. */
  38793. buttonB: number;
  38794. /**
  38795. * Gets the value of the `X` button
  38796. */
  38797. /**
  38798. * Sets the value of the `X` button
  38799. */
  38800. buttonX: number;
  38801. /**
  38802. * Gets the value of the `Y` button
  38803. */
  38804. /**
  38805. * Sets the value of the `Y` button
  38806. */
  38807. buttonY: number;
  38808. /**
  38809. * Gets the value of the `Start` button
  38810. */
  38811. /**
  38812. * Sets the value of the `Start` button
  38813. */
  38814. buttonStart: number;
  38815. /**
  38816. * Gets the value of the `Back` button
  38817. */
  38818. /**
  38819. * Sets the value of the `Back` button
  38820. */
  38821. buttonBack: number;
  38822. /**
  38823. * Gets the value of the `Left` button
  38824. */
  38825. /**
  38826. * Sets the value of the `Left` button
  38827. */
  38828. buttonLB: number;
  38829. /**
  38830. * Gets the value of the `Right` button
  38831. */
  38832. /**
  38833. * Sets the value of the `Right` button
  38834. */
  38835. buttonRB: number;
  38836. /**
  38837. * Gets the value of the Left joystick
  38838. */
  38839. /**
  38840. * Sets the value of the Left joystick
  38841. */
  38842. buttonLeftStick: number;
  38843. /**
  38844. * Gets the value of the Right joystick
  38845. */
  38846. /**
  38847. * Sets the value of the Right joystick
  38848. */
  38849. buttonRightStick: number;
  38850. /**
  38851. * Gets the value of D-pad up
  38852. */
  38853. /**
  38854. * Sets the value of D-pad up
  38855. */
  38856. dPadUp: number;
  38857. /**
  38858. * Gets the value of D-pad down
  38859. */
  38860. /**
  38861. * Sets the value of D-pad down
  38862. */
  38863. dPadDown: number;
  38864. /**
  38865. * Gets the value of D-pad left
  38866. */
  38867. /**
  38868. * Sets the value of D-pad left
  38869. */
  38870. dPadLeft: number;
  38871. /**
  38872. * Gets the value of D-pad right
  38873. */
  38874. /**
  38875. * Sets the value of D-pad right
  38876. */
  38877. dPadRight: number;
  38878. /**
  38879. * Force the gamepad to synchronize with device values
  38880. */
  38881. update(): void;
  38882. /**
  38883. * Disposes the gamepad
  38884. */
  38885. dispose(): void;
  38886. }
  38887. }
  38888. declare module BABYLON {
  38889. /**
  38890. * Defines supported buttons for DualShock compatible gamepads
  38891. */
  38892. export enum DualShockButton {
  38893. /** Cross */
  38894. Cross = 0,
  38895. /** Circle */
  38896. Circle = 1,
  38897. /** Square */
  38898. Square = 2,
  38899. /** Triangle */
  38900. Triangle = 3,
  38901. /** Options */
  38902. Options = 4,
  38903. /** Share */
  38904. Share = 5,
  38905. /** L1 */
  38906. L1 = 6,
  38907. /** R1 */
  38908. R1 = 7,
  38909. /** Left stick */
  38910. LeftStick = 8,
  38911. /** Right stick */
  38912. RightStick = 9
  38913. }
  38914. /** Defines values for DualShock DPad */
  38915. export enum DualShockDpad {
  38916. /** Up */
  38917. Up = 0,
  38918. /** Down */
  38919. Down = 1,
  38920. /** Left */
  38921. Left = 2,
  38922. /** Right */
  38923. Right = 3
  38924. }
  38925. /**
  38926. * Defines a DualShock gamepad
  38927. */
  38928. export class DualShockPad extends Gamepad {
  38929. private _leftTrigger;
  38930. private _rightTrigger;
  38931. private _onlefttriggerchanged;
  38932. private _onrighttriggerchanged;
  38933. private _onbuttondown;
  38934. private _onbuttonup;
  38935. private _ondpaddown;
  38936. private _ondpadup;
  38937. /** Observable raised when a button is pressed */
  38938. onButtonDownObservable: Observable<DualShockButton>;
  38939. /** Observable raised when a button is released */
  38940. onButtonUpObservable: Observable<DualShockButton>;
  38941. /** Observable raised when a pad is pressed */
  38942. onPadDownObservable: Observable<DualShockDpad>;
  38943. /** Observable raised when a pad is released */
  38944. onPadUpObservable: Observable<DualShockDpad>;
  38945. private _buttonCross;
  38946. private _buttonCircle;
  38947. private _buttonSquare;
  38948. private _buttonTriangle;
  38949. private _buttonShare;
  38950. private _buttonOptions;
  38951. private _buttonL1;
  38952. private _buttonR1;
  38953. private _buttonLeftStick;
  38954. private _buttonRightStick;
  38955. private _dPadUp;
  38956. private _dPadDown;
  38957. private _dPadLeft;
  38958. private _dPadRight;
  38959. /**
  38960. * Creates a new DualShock gamepad object
  38961. * @param id defines the id of this gamepad
  38962. * @param index defines its index
  38963. * @param gamepad defines the internal HTML gamepad object
  38964. */
  38965. constructor(id: string, index: number, gamepad: any);
  38966. /**
  38967. * Defines the callback to call when left trigger is pressed
  38968. * @param callback defines the callback to use
  38969. */
  38970. onlefttriggerchanged(callback: (value: number) => void): void;
  38971. /**
  38972. * Defines the callback to call when right trigger is pressed
  38973. * @param callback defines the callback to use
  38974. */
  38975. onrighttriggerchanged(callback: (value: number) => void): void;
  38976. /**
  38977. * Gets the left trigger value
  38978. */
  38979. /**
  38980. * Sets the left trigger value
  38981. */
  38982. leftTrigger: number;
  38983. /**
  38984. * Gets the right trigger value
  38985. */
  38986. /**
  38987. * Sets the right trigger value
  38988. */
  38989. rightTrigger: number;
  38990. /**
  38991. * Defines the callback to call when a button is pressed
  38992. * @param callback defines the callback to use
  38993. */
  38994. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38995. /**
  38996. * Defines the callback to call when a button is released
  38997. * @param callback defines the callback to use
  38998. */
  38999. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39000. /**
  39001. * Defines the callback to call when a pad is pressed
  39002. * @param callback defines the callback to use
  39003. */
  39004. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39005. /**
  39006. * Defines the callback to call when a pad is released
  39007. * @param callback defines the callback to use
  39008. */
  39009. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39010. private _setButtonValue;
  39011. private _setDPadValue;
  39012. /**
  39013. * Gets the value of the `Cross` button
  39014. */
  39015. /**
  39016. * Sets the value of the `Cross` button
  39017. */
  39018. buttonCross: number;
  39019. /**
  39020. * Gets the value of the `Circle` button
  39021. */
  39022. /**
  39023. * Sets the value of the `Circle` button
  39024. */
  39025. buttonCircle: number;
  39026. /**
  39027. * Gets the value of the `Square` button
  39028. */
  39029. /**
  39030. * Sets the value of the `Square` button
  39031. */
  39032. buttonSquare: number;
  39033. /**
  39034. * Gets the value of the `Triangle` button
  39035. */
  39036. /**
  39037. * Sets the value of the `Triangle` button
  39038. */
  39039. buttonTriangle: number;
  39040. /**
  39041. * Gets the value of the `Options` button
  39042. */
  39043. /**
  39044. * Sets the value of the `Options` button
  39045. */
  39046. buttonOptions: number;
  39047. /**
  39048. * Gets the value of the `Share` button
  39049. */
  39050. /**
  39051. * Sets the value of the `Share` button
  39052. */
  39053. buttonShare: number;
  39054. /**
  39055. * Gets the value of the `L1` button
  39056. */
  39057. /**
  39058. * Sets the value of the `L1` button
  39059. */
  39060. buttonL1: number;
  39061. /**
  39062. * Gets the value of the `R1` button
  39063. */
  39064. /**
  39065. * Sets the value of the `R1` button
  39066. */
  39067. buttonR1: number;
  39068. /**
  39069. * Gets the value of the Left joystick
  39070. */
  39071. /**
  39072. * Sets the value of the Left joystick
  39073. */
  39074. buttonLeftStick: number;
  39075. /**
  39076. * Gets the value of the Right joystick
  39077. */
  39078. /**
  39079. * Sets the value of the Right joystick
  39080. */
  39081. buttonRightStick: number;
  39082. /**
  39083. * Gets the value of D-pad up
  39084. */
  39085. /**
  39086. * Sets the value of D-pad up
  39087. */
  39088. dPadUp: number;
  39089. /**
  39090. * Gets the value of D-pad down
  39091. */
  39092. /**
  39093. * Sets the value of D-pad down
  39094. */
  39095. dPadDown: number;
  39096. /**
  39097. * Gets the value of D-pad left
  39098. */
  39099. /**
  39100. * Sets the value of D-pad left
  39101. */
  39102. dPadLeft: number;
  39103. /**
  39104. * Gets the value of D-pad right
  39105. */
  39106. /**
  39107. * Sets the value of D-pad right
  39108. */
  39109. dPadRight: number;
  39110. /**
  39111. * Force the gamepad to synchronize with device values
  39112. */
  39113. update(): void;
  39114. /**
  39115. * Disposes the gamepad
  39116. */
  39117. dispose(): void;
  39118. }
  39119. }
  39120. declare module BABYLON {
  39121. /**
  39122. * Manager for handling gamepads
  39123. */
  39124. export class GamepadManager {
  39125. private _scene?;
  39126. private _babylonGamepads;
  39127. private _oneGamepadConnected;
  39128. /** @hidden */
  39129. _isMonitoring: boolean;
  39130. private _gamepadEventSupported;
  39131. private _gamepadSupport;
  39132. /**
  39133. * observable to be triggered when the gamepad controller has been connected
  39134. */
  39135. onGamepadConnectedObservable: Observable<Gamepad>;
  39136. /**
  39137. * observable to be triggered when the gamepad controller has been disconnected
  39138. */
  39139. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39140. private _onGamepadConnectedEvent;
  39141. private _onGamepadDisconnectedEvent;
  39142. /**
  39143. * Initializes the gamepad manager
  39144. * @param _scene BabylonJS scene
  39145. */
  39146. constructor(_scene?: Scene | undefined);
  39147. /**
  39148. * The gamepads in the game pad manager
  39149. */
  39150. readonly gamepads: Gamepad[];
  39151. /**
  39152. * Get the gamepad controllers based on type
  39153. * @param type The type of gamepad controller
  39154. * @returns Nullable gamepad
  39155. */
  39156. getGamepadByType(type?: number): Nullable<Gamepad>;
  39157. /**
  39158. * Disposes the gamepad manager
  39159. */
  39160. dispose(): void;
  39161. private _addNewGamepad;
  39162. private _startMonitoringGamepads;
  39163. private _stopMonitoringGamepads;
  39164. /** @hidden */
  39165. _checkGamepadsStatus(): void;
  39166. private _updateGamepadObjects;
  39167. }
  39168. }
  39169. declare module BABYLON {
  39170. interface Scene {
  39171. /** @hidden */
  39172. _gamepadManager: Nullable<GamepadManager>;
  39173. /**
  39174. * Gets the gamepad manager associated with the scene
  39175. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39176. */
  39177. gamepadManager: GamepadManager;
  39178. }
  39179. /**
  39180. * Interface representing a free camera inputs manager
  39181. */
  39182. interface FreeCameraInputsManager {
  39183. /**
  39184. * Adds gamepad input support to the FreeCameraInputsManager.
  39185. * @returns the FreeCameraInputsManager
  39186. */
  39187. addGamepad(): FreeCameraInputsManager;
  39188. }
  39189. /**
  39190. * Interface representing an arc rotate camera inputs manager
  39191. */
  39192. interface ArcRotateCameraInputsManager {
  39193. /**
  39194. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39195. * @returns the camera inputs manager
  39196. */
  39197. addGamepad(): ArcRotateCameraInputsManager;
  39198. }
  39199. /**
  39200. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39201. */
  39202. export class GamepadSystemSceneComponent implements ISceneComponent {
  39203. /**
  39204. * The component name helpfull to identify the component in the list of scene components.
  39205. */
  39206. readonly name: string;
  39207. /**
  39208. * The scene the component belongs to.
  39209. */
  39210. scene: Scene;
  39211. /**
  39212. * Creates a new instance of the component for the given scene
  39213. * @param scene Defines the scene to register the component in
  39214. */
  39215. constructor(scene: Scene);
  39216. /**
  39217. * Registers the component in a given scene
  39218. */
  39219. register(): void;
  39220. /**
  39221. * Rebuilds the elements related to this component in case of
  39222. * context lost for instance.
  39223. */
  39224. rebuild(): void;
  39225. /**
  39226. * Disposes the component and the associated ressources
  39227. */
  39228. dispose(): void;
  39229. private _beforeCameraUpdate;
  39230. }
  39231. }
  39232. declare module BABYLON {
  39233. /**
  39234. * 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,
  39235. * which still works and will still be found in many Playgrounds.
  39236. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39237. */
  39238. export class UniversalCamera extends TouchCamera {
  39239. /**
  39240. * Defines the gamepad rotation sensiblity.
  39241. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39242. */
  39243. gamepadAngularSensibility: number;
  39244. /**
  39245. * Defines the gamepad move sensiblity.
  39246. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39247. */
  39248. gamepadMoveSensibility: number;
  39249. /**
  39250. * 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,
  39251. * which still works and will still be found in many Playgrounds.
  39252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39253. * @param name Define the name of the camera in the scene
  39254. * @param position Define the start position of the camera in the scene
  39255. * @param scene Define the scene the camera belongs to
  39256. */
  39257. constructor(name: string, position: Vector3, scene: Scene);
  39258. /**
  39259. * Gets the current object class name.
  39260. * @return the class name
  39261. */
  39262. getClassName(): string;
  39263. }
  39264. }
  39265. declare module BABYLON {
  39266. /**
  39267. * This represents a FPS type of camera. This is only here for back compat purpose.
  39268. * Please use the UniversalCamera instead as both are identical.
  39269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39270. */
  39271. export class GamepadCamera extends UniversalCamera {
  39272. /**
  39273. * Instantiates a new Gamepad Camera
  39274. * This represents a FPS type of camera. This is only here for back compat purpose.
  39275. * Please use the UniversalCamera instead as both are identical.
  39276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39277. * @param name Define the name of the camera in the scene
  39278. * @param position Define the start position of the camera in the scene
  39279. * @param scene Define the scene the camera belongs to
  39280. */
  39281. constructor(name: string, position: Vector3, scene: Scene);
  39282. /**
  39283. * Gets the current object class name.
  39284. * @return the class name
  39285. */
  39286. getClassName(): string;
  39287. }
  39288. }
  39289. declare module BABYLON {
  39290. /** @hidden */
  39291. export var passPixelShader: {
  39292. name: string;
  39293. shader: string;
  39294. };
  39295. }
  39296. declare module BABYLON {
  39297. /** @hidden */
  39298. export var passCubePixelShader: {
  39299. name: string;
  39300. shader: string;
  39301. };
  39302. }
  39303. declare module BABYLON {
  39304. /**
  39305. * PassPostProcess which produces an output the same as it's input
  39306. */
  39307. export class PassPostProcess extends PostProcess {
  39308. /**
  39309. * Creates the PassPostProcess
  39310. * @param name The name of the effect.
  39311. * @param options The required width/height ratio to downsize to before computing the render pass.
  39312. * @param camera The camera to apply the render pass to.
  39313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39314. * @param engine The engine which the post process will be applied. (default: current engine)
  39315. * @param reusable If the post process can be reused on the same frame. (default: false)
  39316. * @param textureType The type of texture to be used when performing the post processing.
  39317. * @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)
  39318. */
  39319. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39320. }
  39321. /**
  39322. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39323. */
  39324. export class PassCubePostProcess extends PostProcess {
  39325. private _face;
  39326. /**
  39327. * Gets or sets the cube face to display.
  39328. * * 0 is +X
  39329. * * 1 is -X
  39330. * * 2 is +Y
  39331. * * 3 is -Y
  39332. * * 4 is +Z
  39333. * * 5 is -Z
  39334. */
  39335. face: number;
  39336. /**
  39337. * Creates the PassCubePostProcess
  39338. * @param name The name of the effect.
  39339. * @param options The required width/height ratio to downsize to before computing the render pass.
  39340. * @param camera The camera to apply the render pass to.
  39341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39342. * @param engine The engine which the post process will be applied. (default: current engine)
  39343. * @param reusable If the post process can be reused on the same frame. (default: false)
  39344. * @param textureType The type of texture to be used when performing the post processing.
  39345. * @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)
  39346. */
  39347. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39348. }
  39349. }
  39350. declare module BABYLON {
  39351. /** @hidden */
  39352. export var anaglyphPixelShader: {
  39353. name: string;
  39354. shader: string;
  39355. };
  39356. }
  39357. declare module BABYLON {
  39358. /**
  39359. * Postprocess used to generate anaglyphic rendering
  39360. */
  39361. export class AnaglyphPostProcess extends PostProcess {
  39362. private _passedProcess;
  39363. /**
  39364. * Creates a new AnaglyphPostProcess
  39365. * @param name defines postprocess name
  39366. * @param options defines creation options or target ratio scale
  39367. * @param rigCameras defines cameras using this postprocess
  39368. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39369. * @param engine defines hosting engine
  39370. * @param reusable defines if the postprocess will be reused multiple times per frame
  39371. */
  39372. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39373. }
  39374. }
  39375. declare module BABYLON {
  39376. /**
  39377. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39378. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39379. */
  39380. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39381. /**
  39382. * Creates a new AnaglyphArcRotateCamera
  39383. * @param name defines camera name
  39384. * @param alpha defines alpha angle (in radians)
  39385. * @param beta defines beta angle (in radians)
  39386. * @param radius defines radius
  39387. * @param target defines camera target
  39388. * @param interaxialDistance defines distance between each color axis
  39389. * @param scene defines the hosting scene
  39390. */
  39391. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39392. /**
  39393. * Gets camera class name
  39394. * @returns AnaglyphArcRotateCamera
  39395. */
  39396. getClassName(): string;
  39397. }
  39398. }
  39399. declare module BABYLON {
  39400. /**
  39401. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39402. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39403. */
  39404. export class AnaglyphFreeCamera extends FreeCamera {
  39405. /**
  39406. * Creates a new AnaglyphFreeCamera
  39407. * @param name defines camera name
  39408. * @param position defines initial position
  39409. * @param interaxialDistance defines distance between each color axis
  39410. * @param scene defines the hosting scene
  39411. */
  39412. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39413. /**
  39414. * Gets camera class name
  39415. * @returns AnaglyphFreeCamera
  39416. */
  39417. getClassName(): string;
  39418. }
  39419. }
  39420. declare module BABYLON {
  39421. /**
  39422. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39423. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39424. */
  39425. export class AnaglyphGamepadCamera extends GamepadCamera {
  39426. /**
  39427. * Creates a new AnaglyphGamepadCamera
  39428. * @param name defines camera name
  39429. * @param position defines initial position
  39430. * @param interaxialDistance defines distance between each color axis
  39431. * @param scene defines the hosting scene
  39432. */
  39433. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39434. /**
  39435. * Gets camera class name
  39436. * @returns AnaglyphGamepadCamera
  39437. */
  39438. getClassName(): string;
  39439. }
  39440. }
  39441. declare module BABYLON {
  39442. /**
  39443. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39444. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39445. */
  39446. export class AnaglyphUniversalCamera extends UniversalCamera {
  39447. /**
  39448. * Creates a new AnaglyphUniversalCamera
  39449. * @param name defines camera name
  39450. * @param position defines initial position
  39451. * @param interaxialDistance defines distance between each color axis
  39452. * @param scene defines the hosting scene
  39453. */
  39454. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39455. /**
  39456. * Gets camera class name
  39457. * @returns AnaglyphUniversalCamera
  39458. */
  39459. getClassName(): string;
  39460. }
  39461. }
  39462. declare module BABYLON {
  39463. /** @hidden */
  39464. export var stereoscopicInterlacePixelShader: {
  39465. name: string;
  39466. shader: string;
  39467. };
  39468. }
  39469. declare module BABYLON {
  39470. /**
  39471. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39472. */
  39473. export class StereoscopicInterlacePostProcess extends PostProcess {
  39474. private _stepSize;
  39475. private _passedProcess;
  39476. /**
  39477. * Initializes a StereoscopicInterlacePostProcess
  39478. * @param name The name of the effect.
  39479. * @param rigCameras The rig cameras to be appled to the post process
  39480. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39482. * @param engine The engine which the post process will be applied. (default: current engine)
  39483. * @param reusable If the post process can be reused on the same frame. (default: false)
  39484. */
  39485. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39486. }
  39487. }
  39488. declare module BABYLON {
  39489. /**
  39490. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39491. * @see http://doc.babylonjs.com/features/cameras
  39492. */
  39493. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39494. /**
  39495. * Creates a new StereoscopicArcRotateCamera
  39496. * @param name defines camera name
  39497. * @param alpha defines alpha angle (in radians)
  39498. * @param beta defines beta angle (in radians)
  39499. * @param radius defines radius
  39500. * @param target defines camera target
  39501. * @param interaxialDistance defines distance between each color axis
  39502. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39503. * @param scene defines the hosting scene
  39504. */
  39505. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39506. /**
  39507. * Gets camera class name
  39508. * @returns StereoscopicArcRotateCamera
  39509. */
  39510. getClassName(): string;
  39511. }
  39512. }
  39513. declare module BABYLON {
  39514. /**
  39515. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39516. * @see http://doc.babylonjs.com/features/cameras
  39517. */
  39518. export class StereoscopicFreeCamera extends FreeCamera {
  39519. /**
  39520. * Creates a new StereoscopicFreeCamera
  39521. * @param name defines camera name
  39522. * @param position defines initial position
  39523. * @param interaxialDistance defines distance between each color axis
  39524. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39525. * @param scene defines the hosting scene
  39526. */
  39527. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39528. /**
  39529. * Gets camera class name
  39530. * @returns StereoscopicFreeCamera
  39531. */
  39532. getClassName(): string;
  39533. }
  39534. }
  39535. declare module BABYLON {
  39536. /**
  39537. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39538. * @see http://doc.babylonjs.com/features/cameras
  39539. */
  39540. export class StereoscopicGamepadCamera extends GamepadCamera {
  39541. /**
  39542. * Creates a new StereoscopicGamepadCamera
  39543. * @param name defines camera name
  39544. * @param position defines initial position
  39545. * @param interaxialDistance defines distance between each color axis
  39546. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39547. * @param scene defines the hosting scene
  39548. */
  39549. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39550. /**
  39551. * Gets camera class name
  39552. * @returns StereoscopicGamepadCamera
  39553. */
  39554. getClassName(): string;
  39555. }
  39556. }
  39557. declare module BABYLON {
  39558. /**
  39559. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39560. * @see http://doc.babylonjs.com/features/cameras
  39561. */
  39562. export class StereoscopicUniversalCamera extends UniversalCamera {
  39563. /**
  39564. * Creates a new StereoscopicUniversalCamera
  39565. * @param name defines camera name
  39566. * @param position defines initial position
  39567. * @param interaxialDistance defines distance between each color axis
  39568. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39569. * @param scene defines the hosting scene
  39570. */
  39571. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39572. /**
  39573. * Gets camera class name
  39574. * @returns StereoscopicUniversalCamera
  39575. */
  39576. getClassName(): string;
  39577. }
  39578. }
  39579. declare module BABYLON {
  39580. /**
  39581. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39582. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39583. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39584. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39585. */
  39586. export class VirtualJoysticksCamera extends FreeCamera {
  39587. /**
  39588. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39589. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39590. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39591. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39592. * @param name Define the name of the camera in the scene
  39593. * @param position Define the start position of the camera in the scene
  39594. * @param scene Define the scene the camera belongs to
  39595. */
  39596. constructor(name: string, position: Vector3, scene: Scene);
  39597. /**
  39598. * Gets the current object class name.
  39599. * @return the class name
  39600. */
  39601. getClassName(): string;
  39602. }
  39603. }
  39604. declare module BABYLON {
  39605. /**
  39606. * This represents all the required metrics to create a VR camera.
  39607. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39608. */
  39609. export class VRCameraMetrics {
  39610. /**
  39611. * Define the horizontal resolution off the screen.
  39612. */
  39613. hResolution: number;
  39614. /**
  39615. * Define the vertical resolution off the screen.
  39616. */
  39617. vResolution: number;
  39618. /**
  39619. * Define the horizontal screen size.
  39620. */
  39621. hScreenSize: number;
  39622. /**
  39623. * Define the vertical screen size.
  39624. */
  39625. vScreenSize: number;
  39626. /**
  39627. * Define the vertical screen center position.
  39628. */
  39629. vScreenCenter: number;
  39630. /**
  39631. * Define the distance of the eyes to the screen.
  39632. */
  39633. eyeToScreenDistance: number;
  39634. /**
  39635. * Define the distance between both lenses
  39636. */
  39637. lensSeparationDistance: number;
  39638. /**
  39639. * Define the distance between both viewer's eyes.
  39640. */
  39641. interpupillaryDistance: number;
  39642. /**
  39643. * Define the distortion factor of the VR postprocess.
  39644. * Please, touch with care.
  39645. */
  39646. distortionK: number[];
  39647. /**
  39648. * Define the chromatic aberration correction factors for the VR post process.
  39649. */
  39650. chromaAbCorrection: number[];
  39651. /**
  39652. * Define the scale factor of the post process.
  39653. * The smaller the better but the slower.
  39654. */
  39655. postProcessScaleFactor: number;
  39656. /**
  39657. * Define an offset for the lens center.
  39658. */
  39659. lensCenterOffset: number;
  39660. /**
  39661. * Define if the current vr camera should compensate the distortion of the lense or not.
  39662. */
  39663. compensateDistortion: boolean;
  39664. /**
  39665. * Defines if multiview should be enabled when rendering (Default: false)
  39666. */
  39667. multiviewEnabled: boolean;
  39668. /**
  39669. * Gets the rendering aspect ratio based on the provided resolutions.
  39670. */
  39671. readonly aspectRatio: number;
  39672. /**
  39673. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39674. */
  39675. readonly aspectRatioFov: number;
  39676. /**
  39677. * @hidden
  39678. */
  39679. readonly leftHMatrix: Matrix;
  39680. /**
  39681. * @hidden
  39682. */
  39683. readonly rightHMatrix: Matrix;
  39684. /**
  39685. * @hidden
  39686. */
  39687. readonly leftPreViewMatrix: Matrix;
  39688. /**
  39689. * @hidden
  39690. */
  39691. readonly rightPreViewMatrix: Matrix;
  39692. /**
  39693. * Get the default VRMetrics based on the most generic setup.
  39694. * @returns the default vr metrics
  39695. */
  39696. static GetDefault(): VRCameraMetrics;
  39697. }
  39698. }
  39699. declare module BABYLON {
  39700. /** @hidden */
  39701. export var vrDistortionCorrectionPixelShader: {
  39702. name: string;
  39703. shader: string;
  39704. };
  39705. }
  39706. declare module BABYLON {
  39707. /**
  39708. * VRDistortionCorrectionPostProcess used for mobile VR
  39709. */
  39710. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39711. private _isRightEye;
  39712. private _distortionFactors;
  39713. private _postProcessScaleFactor;
  39714. private _lensCenterOffset;
  39715. private _scaleIn;
  39716. private _scaleFactor;
  39717. private _lensCenter;
  39718. /**
  39719. * Initializes the VRDistortionCorrectionPostProcess
  39720. * @param name The name of the effect.
  39721. * @param camera The camera to apply the render pass to.
  39722. * @param isRightEye If this is for the right eye distortion
  39723. * @param vrMetrics All the required metrics for the VR camera
  39724. */
  39725. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39726. }
  39727. }
  39728. declare module BABYLON {
  39729. /**
  39730. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39731. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39732. */
  39733. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39734. /**
  39735. * Creates a new VRDeviceOrientationArcRotateCamera
  39736. * @param name defines camera name
  39737. * @param alpha defines the camera rotation along the logitudinal axis
  39738. * @param beta defines the camera rotation along the latitudinal axis
  39739. * @param radius defines the camera distance from its target
  39740. * @param target defines the camera target
  39741. * @param scene defines the scene the camera belongs to
  39742. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39743. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39744. */
  39745. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39746. /**
  39747. * Gets camera class name
  39748. * @returns VRDeviceOrientationArcRotateCamera
  39749. */
  39750. getClassName(): string;
  39751. }
  39752. }
  39753. declare module BABYLON {
  39754. /**
  39755. * Camera used to simulate VR rendering (based on FreeCamera)
  39756. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39757. */
  39758. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39759. /**
  39760. * Creates a new VRDeviceOrientationFreeCamera
  39761. * @param name defines camera name
  39762. * @param position defines the start position of the camera
  39763. * @param scene defines the scene the camera belongs to
  39764. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39765. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39766. */
  39767. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39768. /**
  39769. * Gets camera class name
  39770. * @returns VRDeviceOrientationFreeCamera
  39771. */
  39772. getClassName(): string;
  39773. }
  39774. }
  39775. declare module BABYLON {
  39776. /**
  39777. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39778. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39779. */
  39780. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39781. /**
  39782. * Creates a new VRDeviceOrientationGamepadCamera
  39783. * @param name defines camera name
  39784. * @param position defines the start position of the camera
  39785. * @param scene defines the scene the camera belongs to
  39786. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39787. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39788. */
  39789. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39790. /**
  39791. * Gets camera class name
  39792. * @returns VRDeviceOrientationGamepadCamera
  39793. */
  39794. getClassName(): string;
  39795. }
  39796. }
  39797. declare module BABYLON {
  39798. /**
  39799. * Base class of materials working in push mode in babylon JS
  39800. * @hidden
  39801. */
  39802. export class PushMaterial extends Material {
  39803. protected _activeEffect: Effect;
  39804. protected _normalMatrix: Matrix;
  39805. /**
  39806. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39807. * This means that the material can keep using a previous shader while a new one is being compiled.
  39808. * This is mostly used when shader parallel compilation is supported (true by default)
  39809. */
  39810. allowShaderHotSwapping: boolean;
  39811. constructor(name: string, scene: Scene);
  39812. getEffect(): Effect;
  39813. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39814. /**
  39815. * Binds the given world matrix to the active effect
  39816. *
  39817. * @param world the matrix to bind
  39818. */
  39819. bindOnlyWorldMatrix(world: Matrix): void;
  39820. /**
  39821. * Binds the given normal matrix to the active effect
  39822. *
  39823. * @param normalMatrix the matrix to bind
  39824. */
  39825. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39826. bind(world: Matrix, mesh?: Mesh): void;
  39827. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39828. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39829. }
  39830. }
  39831. declare module BABYLON {
  39832. /**
  39833. * This groups all the flags used to control the materials channel.
  39834. */
  39835. export class MaterialFlags {
  39836. private static _DiffuseTextureEnabled;
  39837. /**
  39838. * Are diffuse textures enabled in the application.
  39839. */
  39840. static DiffuseTextureEnabled: boolean;
  39841. private static _AmbientTextureEnabled;
  39842. /**
  39843. * Are ambient textures enabled in the application.
  39844. */
  39845. static AmbientTextureEnabled: boolean;
  39846. private static _OpacityTextureEnabled;
  39847. /**
  39848. * Are opacity textures enabled in the application.
  39849. */
  39850. static OpacityTextureEnabled: boolean;
  39851. private static _ReflectionTextureEnabled;
  39852. /**
  39853. * Are reflection textures enabled in the application.
  39854. */
  39855. static ReflectionTextureEnabled: boolean;
  39856. private static _EmissiveTextureEnabled;
  39857. /**
  39858. * Are emissive textures enabled in the application.
  39859. */
  39860. static EmissiveTextureEnabled: boolean;
  39861. private static _SpecularTextureEnabled;
  39862. /**
  39863. * Are specular textures enabled in the application.
  39864. */
  39865. static SpecularTextureEnabled: boolean;
  39866. private static _BumpTextureEnabled;
  39867. /**
  39868. * Are bump textures enabled in the application.
  39869. */
  39870. static BumpTextureEnabled: boolean;
  39871. private static _LightmapTextureEnabled;
  39872. /**
  39873. * Are lightmap textures enabled in the application.
  39874. */
  39875. static LightmapTextureEnabled: boolean;
  39876. private static _RefractionTextureEnabled;
  39877. /**
  39878. * Are refraction textures enabled in the application.
  39879. */
  39880. static RefractionTextureEnabled: boolean;
  39881. private static _ColorGradingTextureEnabled;
  39882. /**
  39883. * Are color grading textures enabled in the application.
  39884. */
  39885. static ColorGradingTextureEnabled: boolean;
  39886. private static _FresnelEnabled;
  39887. /**
  39888. * Are fresnels enabled in the application.
  39889. */
  39890. static FresnelEnabled: boolean;
  39891. private static _ClearCoatTextureEnabled;
  39892. /**
  39893. * Are clear coat textures enabled in the application.
  39894. */
  39895. static ClearCoatTextureEnabled: boolean;
  39896. private static _ClearCoatBumpTextureEnabled;
  39897. /**
  39898. * Are clear coat bump textures enabled in the application.
  39899. */
  39900. static ClearCoatBumpTextureEnabled: boolean;
  39901. private static _ClearCoatTintTextureEnabled;
  39902. /**
  39903. * Are clear coat tint textures enabled in the application.
  39904. */
  39905. static ClearCoatTintTextureEnabled: boolean;
  39906. private static _SheenTextureEnabled;
  39907. /**
  39908. * Are sheen textures enabled in the application.
  39909. */
  39910. static SheenTextureEnabled: boolean;
  39911. private static _AnisotropicTextureEnabled;
  39912. /**
  39913. * Are anisotropic textures enabled in the application.
  39914. */
  39915. static AnisotropicTextureEnabled: boolean;
  39916. private static _ThicknessTextureEnabled;
  39917. /**
  39918. * Are thickness textures enabled in the application.
  39919. */
  39920. static ThicknessTextureEnabled: boolean;
  39921. }
  39922. }
  39923. declare module BABYLON {
  39924. /** @hidden */
  39925. export var defaultFragmentDeclaration: {
  39926. name: string;
  39927. shader: string;
  39928. };
  39929. }
  39930. declare module BABYLON {
  39931. /** @hidden */
  39932. export var defaultUboDeclaration: {
  39933. name: string;
  39934. shader: string;
  39935. };
  39936. }
  39937. declare module BABYLON {
  39938. /** @hidden */
  39939. export var lightFragmentDeclaration: {
  39940. name: string;
  39941. shader: string;
  39942. };
  39943. }
  39944. declare module BABYLON {
  39945. /** @hidden */
  39946. export var lightUboDeclaration: {
  39947. name: string;
  39948. shader: string;
  39949. };
  39950. }
  39951. declare module BABYLON {
  39952. /** @hidden */
  39953. export var lightsFragmentFunctions: {
  39954. name: string;
  39955. shader: string;
  39956. };
  39957. }
  39958. declare module BABYLON {
  39959. /** @hidden */
  39960. export var shadowsFragmentFunctions: {
  39961. name: string;
  39962. shader: string;
  39963. };
  39964. }
  39965. declare module BABYLON {
  39966. /** @hidden */
  39967. export var fresnelFunction: {
  39968. name: string;
  39969. shader: string;
  39970. };
  39971. }
  39972. declare module BABYLON {
  39973. /** @hidden */
  39974. export var reflectionFunction: {
  39975. name: string;
  39976. shader: string;
  39977. };
  39978. }
  39979. declare module BABYLON {
  39980. /** @hidden */
  39981. export var bumpFragmentFunctions: {
  39982. name: string;
  39983. shader: string;
  39984. };
  39985. }
  39986. declare module BABYLON {
  39987. /** @hidden */
  39988. export var logDepthDeclaration: {
  39989. name: string;
  39990. shader: string;
  39991. };
  39992. }
  39993. declare module BABYLON {
  39994. /** @hidden */
  39995. export var bumpFragment: {
  39996. name: string;
  39997. shader: string;
  39998. };
  39999. }
  40000. declare module BABYLON {
  40001. /** @hidden */
  40002. export var depthPrePass: {
  40003. name: string;
  40004. shader: string;
  40005. };
  40006. }
  40007. declare module BABYLON {
  40008. /** @hidden */
  40009. export var lightFragment: {
  40010. name: string;
  40011. shader: string;
  40012. };
  40013. }
  40014. declare module BABYLON {
  40015. /** @hidden */
  40016. export var logDepthFragment: {
  40017. name: string;
  40018. shader: string;
  40019. };
  40020. }
  40021. declare module BABYLON {
  40022. /** @hidden */
  40023. export var defaultPixelShader: {
  40024. name: string;
  40025. shader: string;
  40026. };
  40027. }
  40028. declare module BABYLON {
  40029. /** @hidden */
  40030. export var defaultVertexDeclaration: {
  40031. name: string;
  40032. shader: string;
  40033. };
  40034. }
  40035. declare module BABYLON {
  40036. /** @hidden */
  40037. export var bumpVertexDeclaration: {
  40038. name: string;
  40039. shader: string;
  40040. };
  40041. }
  40042. declare module BABYLON {
  40043. /** @hidden */
  40044. export var bumpVertex: {
  40045. name: string;
  40046. shader: string;
  40047. };
  40048. }
  40049. declare module BABYLON {
  40050. /** @hidden */
  40051. export var fogVertex: {
  40052. name: string;
  40053. shader: string;
  40054. };
  40055. }
  40056. declare module BABYLON {
  40057. /** @hidden */
  40058. export var shadowsVertex: {
  40059. name: string;
  40060. shader: string;
  40061. };
  40062. }
  40063. declare module BABYLON {
  40064. /** @hidden */
  40065. export var pointCloudVertex: {
  40066. name: string;
  40067. shader: string;
  40068. };
  40069. }
  40070. declare module BABYLON {
  40071. /** @hidden */
  40072. export var logDepthVertex: {
  40073. name: string;
  40074. shader: string;
  40075. };
  40076. }
  40077. declare module BABYLON {
  40078. /** @hidden */
  40079. export var defaultVertexShader: {
  40080. name: string;
  40081. shader: string;
  40082. };
  40083. }
  40084. declare module BABYLON {
  40085. /** @hidden */
  40086. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40087. MAINUV1: boolean;
  40088. MAINUV2: boolean;
  40089. DIFFUSE: boolean;
  40090. DIFFUSEDIRECTUV: number;
  40091. AMBIENT: boolean;
  40092. AMBIENTDIRECTUV: number;
  40093. OPACITY: boolean;
  40094. OPACITYDIRECTUV: number;
  40095. OPACITYRGB: boolean;
  40096. REFLECTION: boolean;
  40097. EMISSIVE: boolean;
  40098. EMISSIVEDIRECTUV: number;
  40099. SPECULAR: boolean;
  40100. SPECULARDIRECTUV: number;
  40101. BUMP: boolean;
  40102. BUMPDIRECTUV: number;
  40103. PARALLAX: boolean;
  40104. PARALLAXOCCLUSION: boolean;
  40105. SPECULAROVERALPHA: boolean;
  40106. CLIPPLANE: boolean;
  40107. CLIPPLANE2: boolean;
  40108. CLIPPLANE3: boolean;
  40109. CLIPPLANE4: boolean;
  40110. ALPHATEST: boolean;
  40111. DEPTHPREPASS: boolean;
  40112. ALPHAFROMDIFFUSE: boolean;
  40113. POINTSIZE: boolean;
  40114. FOG: boolean;
  40115. SPECULARTERM: boolean;
  40116. DIFFUSEFRESNEL: boolean;
  40117. OPACITYFRESNEL: boolean;
  40118. REFLECTIONFRESNEL: boolean;
  40119. REFRACTIONFRESNEL: boolean;
  40120. EMISSIVEFRESNEL: boolean;
  40121. FRESNEL: boolean;
  40122. NORMAL: boolean;
  40123. UV1: boolean;
  40124. UV2: boolean;
  40125. VERTEXCOLOR: boolean;
  40126. VERTEXALPHA: boolean;
  40127. NUM_BONE_INFLUENCERS: number;
  40128. BonesPerMesh: number;
  40129. BONETEXTURE: boolean;
  40130. INSTANCES: boolean;
  40131. GLOSSINESS: boolean;
  40132. ROUGHNESS: boolean;
  40133. EMISSIVEASILLUMINATION: boolean;
  40134. LINKEMISSIVEWITHDIFFUSE: boolean;
  40135. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40136. LIGHTMAP: boolean;
  40137. LIGHTMAPDIRECTUV: number;
  40138. OBJECTSPACE_NORMALMAP: boolean;
  40139. USELIGHTMAPASSHADOWMAP: boolean;
  40140. REFLECTIONMAP_3D: boolean;
  40141. REFLECTIONMAP_SPHERICAL: boolean;
  40142. REFLECTIONMAP_PLANAR: boolean;
  40143. REFLECTIONMAP_CUBIC: boolean;
  40144. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40145. REFLECTIONMAP_PROJECTION: boolean;
  40146. REFLECTIONMAP_SKYBOX: boolean;
  40147. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40148. REFLECTIONMAP_EXPLICIT: boolean;
  40149. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40150. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40151. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40152. INVERTCUBICMAP: boolean;
  40153. LOGARITHMICDEPTH: boolean;
  40154. REFRACTION: boolean;
  40155. REFRACTIONMAP_3D: boolean;
  40156. REFLECTIONOVERALPHA: boolean;
  40157. TWOSIDEDLIGHTING: boolean;
  40158. SHADOWFLOAT: boolean;
  40159. MORPHTARGETS: boolean;
  40160. MORPHTARGETS_NORMAL: boolean;
  40161. MORPHTARGETS_TANGENT: boolean;
  40162. MORPHTARGETS_UV: boolean;
  40163. NUM_MORPH_INFLUENCERS: number;
  40164. NONUNIFORMSCALING: boolean;
  40165. PREMULTIPLYALPHA: boolean;
  40166. IMAGEPROCESSING: boolean;
  40167. VIGNETTE: boolean;
  40168. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40169. VIGNETTEBLENDMODEOPAQUE: boolean;
  40170. TONEMAPPING: boolean;
  40171. TONEMAPPING_ACES: boolean;
  40172. CONTRAST: boolean;
  40173. COLORCURVES: boolean;
  40174. COLORGRADING: boolean;
  40175. COLORGRADING3D: boolean;
  40176. SAMPLER3DGREENDEPTH: boolean;
  40177. SAMPLER3DBGRMAP: boolean;
  40178. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40179. MULTIVIEW: boolean;
  40180. /**
  40181. * If the reflection texture on this material is in linear color space
  40182. * @hidden
  40183. */
  40184. IS_REFLECTION_LINEAR: boolean;
  40185. /**
  40186. * If the refraction texture on this material is in linear color space
  40187. * @hidden
  40188. */
  40189. IS_REFRACTION_LINEAR: boolean;
  40190. EXPOSURE: boolean;
  40191. constructor();
  40192. setReflectionMode(modeToEnable: string): void;
  40193. }
  40194. /**
  40195. * This is the default material used in Babylon. It is the best trade off between quality
  40196. * and performances.
  40197. * @see http://doc.babylonjs.com/babylon101/materials
  40198. */
  40199. export class StandardMaterial extends PushMaterial {
  40200. private _diffuseTexture;
  40201. /**
  40202. * The basic texture of the material as viewed under a light.
  40203. */
  40204. diffuseTexture: Nullable<BaseTexture>;
  40205. private _ambientTexture;
  40206. /**
  40207. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40208. */
  40209. ambientTexture: Nullable<BaseTexture>;
  40210. private _opacityTexture;
  40211. /**
  40212. * Define the transparency of the material from a texture.
  40213. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40214. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40215. */
  40216. opacityTexture: Nullable<BaseTexture>;
  40217. private _reflectionTexture;
  40218. /**
  40219. * Define the texture used to display the reflection.
  40220. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40221. */
  40222. reflectionTexture: Nullable<BaseTexture>;
  40223. private _emissiveTexture;
  40224. /**
  40225. * Define texture of the material as if self lit.
  40226. * This will be mixed in the final result even in the absence of light.
  40227. */
  40228. emissiveTexture: Nullable<BaseTexture>;
  40229. private _specularTexture;
  40230. /**
  40231. * Define how the color and intensity of the highlight given by the light in the material.
  40232. */
  40233. specularTexture: Nullable<BaseTexture>;
  40234. private _bumpTexture;
  40235. /**
  40236. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40237. * 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.
  40238. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40239. */
  40240. bumpTexture: Nullable<BaseTexture>;
  40241. private _lightmapTexture;
  40242. /**
  40243. * Complex lighting can be computationally expensive to compute at runtime.
  40244. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40245. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40246. */
  40247. lightmapTexture: Nullable<BaseTexture>;
  40248. private _refractionTexture;
  40249. /**
  40250. * Define the texture used to display the refraction.
  40251. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40252. */
  40253. refractionTexture: Nullable<BaseTexture>;
  40254. /**
  40255. * The color of the material lit by the environmental background lighting.
  40256. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40257. */
  40258. ambientColor: Color3;
  40259. /**
  40260. * The basic color of the material as viewed under a light.
  40261. */
  40262. diffuseColor: Color3;
  40263. /**
  40264. * Define how the color and intensity of the highlight given by the light in the material.
  40265. */
  40266. specularColor: Color3;
  40267. /**
  40268. * Define the color of the material as if self lit.
  40269. * This will be mixed in the final result even in the absence of light.
  40270. */
  40271. emissiveColor: Color3;
  40272. /**
  40273. * Defines how sharp are the highlights in the material.
  40274. * The bigger the value the sharper giving a more glossy feeling to the result.
  40275. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40276. */
  40277. specularPower: number;
  40278. private _useAlphaFromDiffuseTexture;
  40279. /**
  40280. * Does the transparency come from the diffuse texture alpha channel.
  40281. */
  40282. useAlphaFromDiffuseTexture: boolean;
  40283. private _useEmissiveAsIllumination;
  40284. /**
  40285. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40286. */
  40287. useEmissiveAsIllumination: boolean;
  40288. private _linkEmissiveWithDiffuse;
  40289. /**
  40290. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40291. * the emissive level when the final color is close to one.
  40292. */
  40293. linkEmissiveWithDiffuse: boolean;
  40294. private _useSpecularOverAlpha;
  40295. /**
  40296. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40297. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40298. */
  40299. useSpecularOverAlpha: boolean;
  40300. private _useReflectionOverAlpha;
  40301. /**
  40302. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40303. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40304. */
  40305. useReflectionOverAlpha: boolean;
  40306. private _disableLighting;
  40307. /**
  40308. * Does lights from the scene impacts this material.
  40309. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40310. */
  40311. disableLighting: boolean;
  40312. private _useObjectSpaceNormalMap;
  40313. /**
  40314. * Allows using an object space normal map (instead of tangent space).
  40315. */
  40316. useObjectSpaceNormalMap: boolean;
  40317. private _useParallax;
  40318. /**
  40319. * Is parallax enabled or not.
  40320. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40321. */
  40322. useParallax: boolean;
  40323. private _useParallaxOcclusion;
  40324. /**
  40325. * Is parallax occlusion enabled or not.
  40326. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40327. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40328. */
  40329. useParallaxOcclusion: boolean;
  40330. /**
  40331. * 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.
  40332. */
  40333. parallaxScaleBias: number;
  40334. private _roughness;
  40335. /**
  40336. * Helps to define how blurry the reflections should appears in the material.
  40337. */
  40338. roughness: number;
  40339. /**
  40340. * In case of refraction, define the value of the index of refraction.
  40341. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40342. */
  40343. indexOfRefraction: number;
  40344. /**
  40345. * Invert the refraction texture alongside the y axis.
  40346. * It can be useful with procedural textures or probe for instance.
  40347. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40348. */
  40349. invertRefractionY: boolean;
  40350. /**
  40351. * Defines the alpha limits in alpha test mode.
  40352. */
  40353. alphaCutOff: number;
  40354. private _useLightmapAsShadowmap;
  40355. /**
  40356. * In case of light mapping, define whether the map contains light or shadow informations.
  40357. */
  40358. useLightmapAsShadowmap: boolean;
  40359. private _diffuseFresnelParameters;
  40360. /**
  40361. * Define the diffuse fresnel parameters of the material.
  40362. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40363. */
  40364. diffuseFresnelParameters: FresnelParameters;
  40365. private _opacityFresnelParameters;
  40366. /**
  40367. * Define the opacity fresnel parameters of the material.
  40368. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40369. */
  40370. opacityFresnelParameters: FresnelParameters;
  40371. private _reflectionFresnelParameters;
  40372. /**
  40373. * Define the reflection fresnel parameters of the material.
  40374. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40375. */
  40376. reflectionFresnelParameters: FresnelParameters;
  40377. private _refractionFresnelParameters;
  40378. /**
  40379. * Define the refraction fresnel parameters of the material.
  40380. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40381. */
  40382. refractionFresnelParameters: FresnelParameters;
  40383. private _emissiveFresnelParameters;
  40384. /**
  40385. * Define the emissive fresnel parameters of the material.
  40386. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40387. */
  40388. emissiveFresnelParameters: FresnelParameters;
  40389. private _useReflectionFresnelFromSpecular;
  40390. /**
  40391. * If true automatically deducts the fresnels values from the material specularity.
  40392. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40393. */
  40394. useReflectionFresnelFromSpecular: boolean;
  40395. private _useGlossinessFromSpecularMapAlpha;
  40396. /**
  40397. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40398. */
  40399. useGlossinessFromSpecularMapAlpha: boolean;
  40400. private _maxSimultaneousLights;
  40401. /**
  40402. * Defines the maximum number of lights that can be used in the material
  40403. */
  40404. maxSimultaneousLights: number;
  40405. private _invertNormalMapX;
  40406. /**
  40407. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40408. */
  40409. invertNormalMapX: boolean;
  40410. private _invertNormalMapY;
  40411. /**
  40412. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40413. */
  40414. invertNormalMapY: boolean;
  40415. private _twoSidedLighting;
  40416. /**
  40417. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40418. */
  40419. twoSidedLighting: boolean;
  40420. /**
  40421. * Default configuration related to image processing available in the standard Material.
  40422. */
  40423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40424. /**
  40425. * Gets the image processing configuration used either in this material.
  40426. */
  40427. /**
  40428. * Sets the Default image processing configuration used either in the this material.
  40429. *
  40430. * If sets to null, the scene one is in use.
  40431. */
  40432. imageProcessingConfiguration: ImageProcessingConfiguration;
  40433. /**
  40434. * Keep track of the image processing observer to allow dispose and replace.
  40435. */
  40436. private _imageProcessingObserver;
  40437. /**
  40438. * Attaches a new image processing configuration to the Standard Material.
  40439. * @param configuration
  40440. */
  40441. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40442. /**
  40443. * Gets wether the color curves effect is enabled.
  40444. */
  40445. /**
  40446. * Sets wether the color curves effect is enabled.
  40447. */
  40448. cameraColorCurvesEnabled: boolean;
  40449. /**
  40450. * Gets wether the color grading effect is enabled.
  40451. */
  40452. /**
  40453. * Gets wether the color grading effect is enabled.
  40454. */
  40455. cameraColorGradingEnabled: boolean;
  40456. /**
  40457. * Gets wether tonemapping is enabled or not.
  40458. */
  40459. /**
  40460. * Sets wether tonemapping is enabled or not
  40461. */
  40462. cameraToneMappingEnabled: boolean;
  40463. /**
  40464. * The camera exposure used on this material.
  40465. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40466. * This corresponds to a photographic exposure.
  40467. */
  40468. /**
  40469. * The camera exposure used on this material.
  40470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40471. * This corresponds to a photographic exposure.
  40472. */
  40473. cameraExposure: number;
  40474. /**
  40475. * Gets The camera contrast used on this material.
  40476. */
  40477. /**
  40478. * Sets The camera contrast used on this material.
  40479. */
  40480. cameraContrast: number;
  40481. /**
  40482. * Gets the Color Grading 2D Lookup Texture.
  40483. */
  40484. /**
  40485. * Sets the Color Grading 2D Lookup Texture.
  40486. */
  40487. cameraColorGradingTexture: Nullable<BaseTexture>;
  40488. /**
  40489. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40490. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40491. * 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;
  40492. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40493. */
  40494. /**
  40495. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40496. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40497. * 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;
  40498. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40499. */
  40500. cameraColorCurves: Nullable<ColorCurves>;
  40501. /**
  40502. * Custom callback helping to override the default shader used in the material.
  40503. */
  40504. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40505. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40506. protected _worldViewProjectionMatrix: Matrix;
  40507. protected _globalAmbientColor: Color3;
  40508. protected _useLogarithmicDepth: boolean;
  40509. protected _rebuildInParallel: boolean;
  40510. /**
  40511. * Instantiates a new standard material.
  40512. * This is the default material used in Babylon. It is the best trade off between quality
  40513. * and performances.
  40514. * @see http://doc.babylonjs.com/babylon101/materials
  40515. * @param name Define the name of the material in the scene
  40516. * @param scene Define the scene the material belong to
  40517. */
  40518. constructor(name: string, scene: Scene);
  40519. /**
  40520. * Gets a boolean indicating that current material needs to register RTT
  40521. */
  40522. readonly hasRenderTargetTextures: boolean;
  40523. /**
  40524. * Gets the current class name of the material e.g. "StandardMaterial"
  40525. * Mainly use in serialization.
  40526. * @returns the class name
  40527. */
  40528. getClassName(): string;
  40529. /**
  40530. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40531. * You can try switching to logarithmic depth.
  40532. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40533. */
  40534. useLogarithmicDepth: boolean;
  40535. /**
  40536. * Specifies if the material will require alpha blending
  40537. * @returns a boolean specifying if alpha blending is needed
  40538. */
  40539. needAlphaBlending(): boolean;
  40540. /**
  40541. * Specifies if this material should be rendered in alpha test mode
  40542. * @returns a boolean specifying if an alpha test is needed.
  40543. */
  40544. needAlphaTesting(): boolean;
  40545. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40546. /**
  40547. * Get the texture used for alpha test purpose.
  40548. * @returns the diffuse texture in case of the standard material.
  40549. */
  40550. getAlphaTestTexture(): Nullable<BaseTexture>;
  40551. /**
  40552. * Get if the submesh is ready to be used and all its information available.
  40553. * Child classes can use it to update shaders
  40554. * @param mesh defines the mesh to check
  40555. * @param subMesh defines which submesh to check
  40556. * @param useInstances specifies that instances should be used
  40557. * @returns a boolean indicating that the submesh is ready or not
  40558. */
  40559. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40560. /**
  40561. * Builds the material UBO layouts.
  40562. * Used internally during the effect preparation.
  40563. */
  40564. buildUniformLayout(): void;
  40565. /**
  40566. * Unbinds the material from the mesh
  40567. */
  40568. unbind(): void;
  40569. /**
  40570. * Binds the submesh to this material by preparing the effect and shader to draw
  40571. * @param world defines the world transformation matrix
  40572. * @param mesh defines the mesh containing the submesh
  40573. * @param subMesh defines the submesh to bind the material to
  40574. */
  40575. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40576. /**
  40577. * Get the list of animatables in the material.
  40578. * @returns the list of animatables object used in the material
  40579. */
  40580. getAnimatables(): IAnimatable[];
  40581. /**
  40582. * Gets the active textures from the material
  40583. * @returns an array of textures
  40584. */
  40585. getActiveTextures(): BaseTexture[];
  40586. /**
  40587. * Specifies if the material uses a texture
  40588. * @param texture defines the texture to check against the material
  40589. * @returns a boolean specifying if the material uses the texture
  40590. */
  40591. hasTexture(texture: BaseTexture): boolean;
  40592. /**
  40593. * Disposes the material
  40594. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40595. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40596. */
  40597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40598. /**
  40599. * Makes a duplicate of the material, and gives it a new name
  40600. * @param name defines the new name for the duplicated material
  40601. * @returns the cloned material
  40602. */
  40603. clone(name: string): StandardMaterial;
  40604. /**
  40605. * Serializes this material in a JSON representation
  40606. * @returns the serialized material object
  40607. */
  40608. serialize(): any;
  40609. /**
  40610. * Creates a standard material from parsed material data
  40611. * @param source defines the JSON representation of the material
  40612. * @param scene defines the hosting scene
  40613. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40614. * @returns a new standard material
  40615. */
  40616. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40617. /**
  40618. * Are diffuse textures enabled in the application.
  40619. */
  40620. static DiffuseTextureEnabled: boolean;
  40621. /**
  40622. * Are ambient textures enabled in the application.
  40623. */
  40624. static AmbientTextureEnabled: boolean;
  40625. /**
  40626. * Are opacity textures enabled in the application.
  40627. */
  40628. static OpacityTextureEnabled: boolean;
  40629. /**
  40630. * Are reflection textures enabled in the application.
  40631. */
  40632. static ReflectionTextureEnabled: boolean;
  40633. /**
  40634. * Are emissive textures enabled in the application.
  40635. */
  40636. static EmissiveTextureEnabled: boolean;
  40637. /**
  40638. * Are specular textures enabled in the application.
  40639. */
  40640. static SpecularTextureEnabled: boolean;
  40641. /**
  40642. * Are bump textures enabled in the application.
  40643. */
  40644. static BumpTextureEnabled: boolean;
  40645. /**
  40646. * Are lightmap textures enabled in the application.
  40647. */
  40648. static LightmapTextureEnabled: boolean;
  40649. /**
  40650. * Are refraction textures enabled in the application.
  40651. */
  40652. static RefractionTextureEnabled: boolean;
  40653. /**
  40654. * Are color grading textures enabled in the application.
  40655. */
  40656. static ColorGradingTextureEnabled: boolean;
  40657. /**
  40658. * Are fresnels enabled in the application.
  40659. */
  40660. static FresnelEnabled: boolean;
  40661. }
  40662. }
  40663. declare module BABYLON {
  40664. /** @hidden */
  40665. export var imageProcessingPixelShader: {
  40666. name: string;
  40667. shader: string;
  40668. };
  40669. }
  40670. declare module BABYLON {
  40671. /**
  40672. * ImageProcessingPostProcess
  40673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40674. */
  40675. export class ImageProcessingPostProcess extends PostProcess {
  40676. /**
  40677. * Default configuration related to image processing available in the PBR Material.
  40678. */
  40679. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40680. /**
  40681. * Gets the image processing configuration used either in this material.
  40682. */
  40683. /**
  40684. * Sets the Default image processing configuration used either in the this material.
  40685. *
  40686. * If sets to null, the scene one is in use.
  40687. */
  40688. imageProcessingConfiguration: ImageProcessingConfiguration;
  40689. /**
  40690. * Keep track of the image processing observer to allow dispose and replace.
  40691. */
  40692. private _imageProcessingObserver;
  40693. /**
  40694. * Attaches a new image processing configuration to the PBR Material.
  40695. * @param configuration
  40696. */
  40697. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40698. /**
  40699. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40700. */
  40701. /**
  40702. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40703. */
  40704. colorCurves: Nullable<ColorCurves>;
  40705. /**
  40706. * Gets wether the color curves effect is enabled.
  40707. */
  40708. /**
  40709. * Sets wether the color curves effect is enabled.
  40710. */
  40711. colorCurvesEnabled: boolean;
  40712. /**
  40713. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40714. */
  40715. /**
  40716. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40717. */
  40718. colorGradingTexture: Nullable<BaseTexture>;
  40719. /**
  40720. * Gets wether the color grading effect is enabled.
  40721. */
  40722. /**
  40723. * Gets wether the color grading effect is enabled.
  40724. */
  40725. colorGradingEnabled: boolean;
  40726. /**
  40727. * Gets exposure used in the effect.
  40728. */
  40729. /**
  40730. * Sets exposure used in the effect.
  40731. */
  40732. exposure: number;
  40733. /**
  40734. * Gets wether tonemapping is enabled or not.
  40735. */
  40736. /**
  40737. * Sets wether tonemapping is enabled or not
  40738. */
  40739. toneMappingEnabled: boolean;
  40740. /**
  40741. * Gets the type of tone mapping effect.
  40742. */
  40743. /**
  40744. * Sets the type of tone mapping effect.
  40745. */
  40746. toneMappingType: number;
  40747. /**
  40748. * Gets contrast used in the effect.
  40749. */
  40750. /**
  40751. * Sets contrast used in the effect.
  40752. */
  40753. contrast: number;
  40754. /**
  40755. * Gets Vignette stretch size.
  40756. */
  40757. /**
  40758. * Sets Vignette stretch size.
  40759. */
  40760. vignetteStretch: number;
  40761. /**
  40762. * Gets Vignette centre X Offset.
  40763. */
  40764. /**
  40765. * Sets Vignette centre X Offset.
  40766. */
  40767. vignetteCentreX: number;
  40768. /**
  40769. * Gets Vignette centre Y Offset.
  40770. */
  40771. /**
  40772. * Sets Vignette centre Y Offset.
  40773. */
  40774. vignetteCentreY: number;
  40775. /**
  40776. * Gets Vignette weight or intensity of the vignette effect.
  40777. */
  40778. /**
  40779. * Sets Vignette weight or intensity of the vignette effect.
  40780. */
  40781. vignetteWeight: number;
  40782. /**
  40783. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40784. * if vignetteEnabled is set to true.
  40785. */
  40786. /**
  40787. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40788. * if vignetteEnabled is set to true.
  40789. */
  40790. vignetteColor: Color4;
  40791. /**
  40792. * Gets Camera field of view used by the Vignette effect.
  40793. */
  40794. /**
  40795. * Sets Camera field of view used by the Vignette effect.
  40796. */
  40797. vignetteCameraFov: number;
  40798. /**
  40799. * Gets the vignette blend mode allowing different kind of effect.
  40800. */
  40801. /**
  40802. * Sets the vignette blend mode allowing different kind of effect.
  40803. */
  40804. vignetteBlendMode: number;
  40805. /**
  40806. * Gets wether the vignette effect is enabled.
  40807. */
  40808. /**
  40809. * Sets wether the vignette effect is enabled.
  40810. */
  40811. vignetteEnabled: boolean;
  40812. private _fromLinearSpace;
  40813. /**
  40814. * Gets wether the input of the processing is in Gamma or Linear Space.
  40815. */
  40816. /**
  40817. * Sets wether the input of the processing is in Gamma or Linear Space.
  40818. */
  40819. fromLinearSpace: boolean;
  40820. /**
  40821. * Defines cache preventing GC.
  40822. */
  40823. private _defines;
  40824. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40825. /**
  40826. * "ImageProcessingPostProcess"
  40827. * @returns "ImageProcessingPostProcess"
  40828. */
  40829. getClassName(): string;
  40830. protected _updateParameters(): void;
  40831. dispose(camera?: Camera): void;
  40832. }
  40833. }
  40834. declare module BABYLON {
  40835. /**
  40836. * Class containing static functions to help procedurally build meshes
  40837. */
  40838. export class GroundBuilder {
  40839. /**
  40840. * Creates a ground mesh
  40841. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40842. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40844. * @param name defines the name of the mesh
  40845. * @param options defines the options used to create the mesh
  40846. * @param scene defines the hosting scene
  40847. * @returns the ground mesh
  40848. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40849. */
  40850. static CreateGround(name: string, options: {
  40851. width?: number;
  40852. height?: number;
  40853. subdivisions?: number;
  40854. subdivisionsX?: number;
  40855. subdivisionsY?: number;
  40856. updatable?: boolean;
  40857. }, scene: any): Mesh;
  40858. /**
  40859. * Creates a tiled ground mesh
  40860. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40861. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40862. * * 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
  40863. * * 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
  40864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40865. * @param name defines the name of the mesh
  40866. * @param options defines the options used to create the mesh
  40867. * @param scene defines the hosting scene
  40868. * @returns the tiled ground mesh
  40869. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40870. */
  40871. static CreateTiledGround(name: string, options: {
  40872. xmin: number;
  40873. zmin: number;
  40874. xmax: number;
  40875. zmax: number;
  40876. subdivisions?: {
  40877. w: number;
  40878. h: number;
  40879. };
  40880. precision?: {
  40881. w: number;
  40882. h: number;
  40883. };
  40884. updatable?: boolean;
  40885. }, scene?: Nullable<Scene>): Mesh;
  40886. /**
  40887. * Creates a ground mesh from a height map
  40888. * * The parameter `url` sets the URL of the height map image resource.
  40889. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40890. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40891. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40892. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40893. * * 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.
  40894. * * 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).
  40895. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40897. * @param name defines the name of the mesh
  40898. * @param url defines the url to the height map
  40899. * @param options defines the options used to create the mesh
  40900. * @param scene defines the hosting scene
  40901. * @returns the ground mesh
  40902. * @see https://doc.babylonjs.com/babylon101/height_map
  40903. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40904. */
  40905. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40906. width?: number;
  40907. height?: number;
  40908. subdivisions?: number;
  40909. minHeight?: number;
  40910. maxHeight?: number;
  40911. colorFilter?: Color3;
  40912. alphaFilter?: number;
  40913. updatable?: boolean;
  40914. onReady?: (mesh: GroundMesh) => void;
  40915. }, scene?: Nullable<Scene>): GroundMesh;
  40916. }
  40917. }
  40918. declare module BABYLON {
  40919. /**
  40920. * Class containing static functions to help procedurally build meshes
  40921. */
  40922. export class TorusBuilder {
  40923. /**
  40924. * Creates a torus mesh
  40925. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40926. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40927. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40929. * * 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
  40930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40931. * @param name defines the name of the mesh
  40932. * @param options defines the options used to create the mesh
  40933. * @param scene defines the hosting scene
  40934. * @returns the torus mesh
  40935. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40936. */
  40937. static CreateTorus(name: string, options: {
  40938. diameter?: number;
  40939. thickness?: number;
  40940. tessellation?: number;
  40941. updatable?: boolean;
  40942. sideOrientation?: number;
  40943. frontUVs?: Vector4;
  40944. backUVs?: Vector4;
  40945. }, scene: any): Mesh;
  40946. }
  40947. }
  40948. declare module BABYLON {
  40949. /**
  40950. * Class containing static functions to help procedurally build meshes
  40951. */
  40952. export class CylinderBuilder {
  40953. /**
  40954. * Creates a cylinder or a cone mesh
  40955. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40956. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40957. * * 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.
  40958. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40959. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40960. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40961. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40962. * * 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).
  40963. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40964. * * 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).
  40965. * * 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
  40966. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40967. * * 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
  40968. * * 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.
  40969. * * If `enclose` is false, a ring surface is one element.
  40970. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40971. * * 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
  40972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40973. * * 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
  40974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40975. * @param name defines the name of the mesh
  40976. * @param options defines the options used to create the mesh
  40977. * @param scene defines the hosting scene
  40978. * @returns the cylinder mesh
  40979. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40980. */
  40981. static CreateCylinder(name: string, options: {
  40982. height?: number;
  40983. diameterTop?: number;
  40984. diameterBottom?: number;
  40985. diameter?: number;
  40986. tessellation?: number;
  40987. subdivisions?: number;
  40988. arc?: number;
  40989. faceColors?: Color4[];
  40990. faceUV?: Vector4[];
  40991. updatable?: boolean;
  40992. hasRings?: boolean;
  40993. enclose?: boolean;
  40994. cap?: number;
  40995. sideOrientation?: number;
  40996. frontUVs?: Vector4;
  40997. backUVs?: Vector4;
  40998. }, scene: any): Mesh;
  40999. }
  41000. }
  41001. declare module BABYLON {
  41002. /**
  41003. * Options to modify the vr teleportation behavior.
  41004. */
  41005. export interface VRTeleportationOptions {
  41006. /**
  41007. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41008. */
  41009. floorMeshName?: string;
  41010. /**
  41011. * A list of meshes to be used as the teleportation floor. (default: empty)
  41012. */
  41013. floorMeshes?: Mesh[];
  41014. }
  41015. /**
  41016. * Options to modify the vr experience helper's behavior.
  41017. */
  41018. export interface VRExperienceHelperOptions extends WebVROptions {
  41019. /**
  41020. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41021. */
  41022. createDeviceOrientationCamera?: boolean;
  41023. /**
  41024. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41025. */
  41026. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41027. /**
  41028. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41029. */
  41030. laserToggle?: boolean;
  41031. /**
  41032. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41033. */
  41034. floorMeshes?: Mesh[];
  41035. /**
  41036. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41037. */
  41038. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41039. }
  41040. /**
  41041. * Event containing information after VR has been entered
  41042. */
  41043. export class OnAfterEnteringVRObservableEvent {
  41044. /**
  41045. * If entering vr was successful
  41046. */
  41047. success: boolean;
  41048. }
  41049. /**
  41050. * Helps to quickly add VR support to an existing scene.
  41051. * See http://doc.babylonjs.com/how_to/webvr_helper
  41052. */
  41053. export class VRExperienceHelper {
  41054. /** Options to modify the vr experience helper's behavior. */
  41055. webVROptions: VRExperienceHelperOptions;
  41056. private _scene;
  41057. private _position;
  41058. private _btnVR;
  41059. private _btnVRDisplayed;
  41060. private _webVRsupported;
  41061. private _webVRready;
  41062. private _webVRrequesting;
  41063. private _webVRpresenting;
  41064. private _hasEnteredVR;
  41065. private _fullscreenVRpresenting;
  41066. private _canvas;
  41067. private _webVRCamera;
  41068. private _vrDeviceOrientationCamera;
  41069. private _deviceOrientationCamera;
  41070. private _existingCamera;
  41071. private _onKeyDown;
  41072. private _onVrDisplayPresentChange;
  41073. private _onVRDisplayChanged;
  41074. private _onVRRequestPresentStart;
  41075. private _onVRRequestPresentComplete;
  41076. /**
  41077. * 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)
  41078. */
  41079. enableGazeEvenWhenNoPointerLock: boolean;
  41080. /**
  41081. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41082. */
  41083. exitVROnDoubleTap: boolean;
  41084. /**
  41085. * Observable raised right before entering VR.
  41086. */
  41087. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41088. /**
  41089. * Observable raised when entering VR has completed.
  41090. */
  41091. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41092. /**
  41093. * Observable raised when exiting VR.
  41094. */
  41095. onExitingVRObservable: Observable<VRExperienceHelper>;
  41096. /**
  41097. * Observable raised when controller mesh is loaded.
  41098. */
  41099. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41100. /** Return this.onEnteringVRObservable
  41101. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41102. */
  41103. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41104. /** Return this.onExitingVRObservable
  41105. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41106. */
  41107. readonly onExitingVR: Observable<VRExperienceHelper>;
  41108. /** Return this.onControllerMeshLoadedObservable
  41109. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41110. */
  41111. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41112. private _rayLength;
  41113. private _useCustomVRButton;
  41114. private _teleportationRequested;
  41115. private _teleportActive;
  41116. private _floorMeshName;
  41117. private _floorMeshesCollection;
  41118. private _rotationAllowed;
  41119. private _teleportBackwardsVector;
  41120. private _teleportationTarget;
  41121. private _isDefaultTeleportationTarget;
  41122. private _postProcessMove;
  41123. private _teleportationFillColor;
  41124. private _teleportationBorderColor;
  41125. private _rotationAngle;
  41126. private _haloCenter;
  41127. private _cameraGazer;
  41128. private _padSensibilityUp;
  41129. private _padSensibilityDown;
  41130. private _leftController;
  41131. private _rightController;
  41132. /**
  41133. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41134. */
  41135. onNewMeshSelected: Observable<AbstractMesh>;
  41136. /**
  41137. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41138. * This observable will provide the mesh and the controller used to select the mesh
  41139. */
  41140. onMeshSelectedWithController: Observable<{
  41141. mesh: AbstractMesh;
  41142. controller: WebVRController;
  41143. }>;
  41144. /**
  41145. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41146. */
  41147. onNewMeshPicked: Observable<PickingInfo>;
  41148. private _circleEase;
  41149. /**
  41150. * Observable raised before camera teleportation
  41151. */
  41152. onBeforeCameraTeleport: Observable<Vector3>;
  41153. /**
  41154. * Observable raised after camera teleportation
  41155. */
  41156. onAfterCameraTeleport: Observable<Vector3>;
  41157. /**
  41158. * Observable raised when current selected mesh gets unselected
  41159. */
  41160. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41161. private _raySelectionPredicate;
  41162. /**
  41163. * To be optionaly changed by user to define custom ray selection
  41164. */
  41165. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41166. /**
  41167. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41168. */
  41169. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41170. /**
  41171. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41172. */
  41173. teleportationEnabled: boolean;
  41174. private _defaultHeight;
  41175. private _teleportationInitialized;
  41176. private _interactionsEnabled;
  41177. private _interactionsRequested;
  41178. private _displayGaze;
  41179. private _displayLaserPointer;
  41180. /**
  41181. * The mesh used to display where the user is going to teleport.
  41182. */
  41183. /**
  41184. * Sets the mesh to be used to display where the user is going to teleport.
  41185. */
  41186. teleportationTarget: Mesh;
  41187. /**
  41188. * 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
  41189. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41190. * See http://doc.babylonjs.com/resources/baking_transformations
  41191. */
  41192. gazeTrackerMesh: Mesh;
  41193. /**
  41194. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41195. */
  41196. updateGazeTrackerScale: boolean;
  41197. /**
  41198. * If the gaze trackers color should be updated when selecting meshes
  41199. */
  41200. updateGazeTrackerColor: boolean;
  41201. /**
  41202. * If the controller laser color should be updated when selecting meshes
  41203. */
  41204. updateControllerLaserColor: boolean;
  41205. /**
  41206. * The gaze tracking mesh corresponding to the left controller
  41207. */
  41208. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41209. /**
  41210. * The gaze tracking mesh corresponding to the right controller
  41211. */
  41212. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41213. /**
  41214. * If the ray of the gaze should be displayed.
  41215. */
  41216. /**
  41217. * Sets if the ray of the gaze should be displayed.
  41218. */
  41219. displayGaze: boolean;
  41220. /**
  41221. * If the ray of the LaserPointer should be displayed.
  41222. */
  41223. /**
  41224. * Sets if the ray of the LaserPointer should be displayed.
  41225. */
  41226. displayLaserPointer: boolean;
  41227. /**
  41228. * The deviceOrientationCamera used as the camera when not in VR.
  41229. */
  41230. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41231. /**
  41232. * Based on the current WebVR support, returns the current VR camera used.
  41233. */
  41234. readonly currentVRCamera: Nullable<Camera>;
  41235. /**
  41236. * The webVRCamera which is used when in VR.
  41237. */
  41238. readonly webVRCamera: WebVRFreeCamera;
  41239. /**
  41240. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41241. */
  41242. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41243. /**
  41244. * The html button that is used to trigger entering into VR.
  41245. */
  41246. readonly vrButton: Nullable<HTMLButtonElement>;
  41247. private readonly _teleportationRequestInitiated;
  41248. /**
  41249. * Defines wether or not Pointer lock should be requested when switching to
  41250. * full screen.
  41251. */
  41252. requestPointerLockOnFullScreen: boolean;
  41253. /**
  41254. * Instantiates a VRExperienceHelper.
  41255. * Helps to quickly add VR support to an existing scene.
  41256. * @param scene The scene the VRExperienceHelper belongs to.
  41257. * @param webVROptions Options to modify the vr experience helper's behavior.
  41258. */
  41259. constructor(scene: Scene,
  41260. /** Options to modify the vr experience helper's behavior. */
  41261. webVROptions?: VRExperienceHelperOptions);
  41262. private _onDefaultMeshLoaded;
  41263. private _onResize;
  41264. private _onFullscreenChange;
  41265. /**
  41266. * Gets a value indicating if we are currently in VR mode.
  41267. */
  41268. readonly isInVRMode: boolean;
  41269. private onVrDisplayPresentChange;
  41270. private onVRDisplayChanged;
  41271. private moveButtonToBottomRight;
  41272. private displayVRButton;
  41273. private updateButtonVisibility;
  41274. private _cachedAngularSensibility;
  41275. /**
  41276. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41277. * Otherwise, will use the fullscreen API.
  41278. */
  41279. enterVR(): void;
  41280. /**
  41281. * Attempt to exit VR, or fullscreen.
  41282. */
  41283. exitVR(): void;
  41284. /**
  41285. * The position of the vr experience helper.
  41286. */
  41287. /**
  41288. * Sets the position of the vr experience helper.
  41289. */
  41290. position: Vector3;
  41291. /**
  41292. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41293. */
  41294. enableInteractions(): void;
  41295. private readonly _noControllerIsActive;
  41296. private beforeRender;
  41297. private _isTeleportationFloor;
  41298. /**
  41299. * Adds a floor mesh to be used for teleportation.
  41300. * @param floorMesh the mesh to be used for teleportation.
  41301. */
  41302. addFloorMesh(floorMesh: Mesh): void;
  41303. /**
  41304. * Removes a floor mesh from being used for teleportation.
  41305. * @param floorMesh the mesh to be removed.
  41306. */
  41307. removeFloorMesh(floorMesh: Mesh): void;
  41308. /**
  41309. * Enables interactions and teleportation using the VR controllers and gaze.
  41310. * @param vrTeleportationOptions options to modify teleportation behavior.
  41311. */
  41312. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41313. private _onNewGamepadConnected;
  41314. private _tryEnableInteractionOnController;
  41315. private _onNewGamepadDisconnected;
  41316. private _enableInteractionOnController;
  41317. private _checkTeleportWithRay;
  41318. private _checkRotate;
  41319. private _checkTeleportBackwards;
  41320. private _enableTeleportationOnController;
  41321. private _createTeleportationCircles;
  41322. private _displayTeleportationTarget;
  41323. private _hideTeleportationTarget;
  41324. private _rotateCamera;
  41325. private _moveTeleportationSelectorTo;
  41326. private _workingVector;
  41327. private _workingQuaternion;
  41328. private _workingMatrix;
  41329. /**
  41330. * Teleports the users feet to the desired location
  41331. * @param location The location where the user's feet should be placed
  41332. */
  41333. teleportCamera(location: Vector3): void;
  41334. private _convertNormalToDirectionOfRay;
  41335. private _castRayAndSelectObject;
  41336. private _notifySelectedMeshUnselected;
  41337. /**
  41338. * Sets the color of the laser ray from the vr controllers.
  41339. * @param color new color for the ray.
  41340. */
  41341. changeLaserColor(color: Color3): void;
  41342. /**
  41343. * Sets the color of the ray from the vr headsets gaze.
  41344. * @param color new color for the ray.
  41345. */
  41346. changeGazeColor(color: Color3): void;
  41347. /**
  41348. * Exits VR and disposes of the vr experience helper
  41349. */
  41350. dispose(): void;
  41351. /**
  41352. * Gets the name of the VRExperienceHelper class
  41353. * @returns "VRExperienceHelper"
  41354. */
  41355. getClassName(): string;
  41356. }
  41357. }
  41358. declare module BABYLON {
  41359. /**
  41360. * Manages an XRSession to work with Babylon's engine
  41361. * @see https://doc.babylonjs.com/how_to/webxr
  41362. */
  41363. export class WebXRSessionManager implements IDisposable {
  41364. private scene;
  41365. /**
  41366. * Fires every time a new xrFrame arrives which can be used to update the camera
  41367. */
  41368. onXRFrameObservable: Observable<any>;
  41369. /**
  41370. * Fires when the xr session is ended either by the device or manually done
  41371. */
  41372. onXRSessionEnded: Observable<any>;
  41373. /**
  41374. * Underlying xr session
  41375. */
  41376. session: XRSession;
  41377. /**
  41378. * Type of reference space used when creating the session
  41379. */
  41380. referenceSpace: XRReferenceSpace;
  41381. /** @hidden */
  41382. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41383. /**
  41384. * Current XR frame
  41385. */
  41386. currentFrame: Nullable<XRFrame>;
  41387. private _xrNavigator;
  41388. private baseLayer;
  41389. /**
  41390. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41391. * @param scene The scene which the session should be created for
  41392. */
  41393. constructor(scene: Scene);
  41394. /**
  41395. * Initializes the manager
  41396. * After initialization enterXR can be called to start an XR session
  41397. * @returns Promise which resolves after it is initialized
  41398. */
  41399. initializeAsync(): Promise<void>;
  41400. /**
  41401. * Initializes an xr session
  41402. * @param xrSessionMode mode to initialize
  41403. * @returns a promise which will resolve once the session has been initialized
  41404. */
  41405. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41406. /**
  41407. * Sets the reference space on the xr session
  41408. * @param referenceSpace space to set
  41409. * @returns a promise that will resolve once the reference space has been set
  41410. */
  41411. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41412. /**
  41413. * Updates the render state of the session
  41414. * @param state state to set
  41415. * @returns a promise that resolves once the render state has been updated
  41416. */
  41417. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41418. /**
  41419. * Starts rendering to the xr layer
  41420. * @returns a promise that will resolve once rendering has started
  41421. */
  41422. startRenderingToXRAsync(): Promise<void>;
  41423. /**
  41424. * Stops the xrSession and restores the renderloop
  41425. * @returns Promise which resolves after it exits XR
  41426. */
  41427. exitXRAsync(): Promise<unknown>;
  41428. /**
  41429. * Checks if a session would be supported for the creation options specified
  41430. * @param sessionMode session mode to check if supported eg. immersive-vr
  41431. * @returns true if supported
  41432. */
  41433. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41434. /**
  41435. * @hidden
  41436. * Converts the render layer of xrSession to a render target
  41437. * @param session session to create render target for
  41438. * @param scene scene the new render target should be created for
  41439. */
  41440. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41441. /**
  41442. * Disposes of the session manager
  41443. */
  41444. dispose(): void;
  41445. }
  41446. }
  41447. declare module BABYLON {
  41448. /**
  41449. * WebXR Camera which holds the views for the xrSession
  41450. * @see https://doc.babylonjs.com/how_to/webxr
  41451. */
  41452. export class WebXRCamera extends FreeCamera {
  41453. private static _TmpMatrix;
  41454. /**
  41455. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41456. * @param name the name of the camera
  41457. * @param scene the scene to add the camera to
  41458. */
  41459. constructor(name: string, scene: Scene);
  41460. private _updateNumberOfRigCameras;
  41461. /** @hidden */
  41462. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41463. /**
  41464. * Updates the cameras position from the current pose information of the XR session
  41465. * @param xrSessionManager the session containing pose information
  41466. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41467. */
  41468. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41469. }
  41470. }
  41471. declare module BABYLON {
  41472. /**
  41473. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41474. */
  41475. export class WebXRManagedOutputCanvas implements IDisposable {
  41476. private helper;
  41477. private _canvas;
  41478. /**
  41479. * xrpresent context of the canvas which can be used to display/mirror xr content
  41480. */
  41481. canvasContext: WebGLRenderingContext;
  41482. /**
  41483. * xr layer for the canvas
  41484. */
  41485. xrLayer: Nullable<XRWebGLLayer>;
  41486. /**
  41487. * Initializes the xr layer for the session
  41488. * @param xrSession xr session
  41489. * @returns a promise that will resolve once the XR Layer has been created
  41490. */
  41491. initializeXRLayerAsync(xrSession: any): any;
  41492. /**
  41493. * Initializes the canvas to be added/removed upon entering/exiting xr
  41494. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41495. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41496. */
  41497. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41498. /**
  41499. * Disposes of the object
  41500. */
  41501. dispose(): void;
  41502. private _setManagedOutputCanvas;
  41503. private _addCanvas;
  41504. private _removeCanvas;
  41505. }
  41506. }
  41507. declare module BABYLON {
  41508. /**
  41509. * States of the webXR experience
  41510. */
  41511. export enum WebXRState {
  41512. /**
  41513. * Transitioning to being in XR mode
  41514. */
  41515. ENTERING_XR = 0,
  41516. /**
  41517. * Transitioning to non XR mode
  41518. */
  41519. EXITING_XR = 1,
  41520. /**
  41521. * In XR mode and presenting
  41522. */
  41523. IN_XR = 2,
  41524. /**
  41525. * Not entered XR mode
  41526. */
  41527. NOT_IN_XR = 3
  41528. }
  41529. /**
  41530. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41531. * @see https://doc.babylonjs.com/how_to/webxr
  41532. */
  41533. export class WebXRExperienceHelper implements IDisposable {
  41534. private scene;
  41535. /**
  41536. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41537. */
  41538. container: AbstractMesh;
  41539. /**
  41540. * Camera used to render xr content
  41541. */
  41542. camera: WebXRCamera;
  41543. /**
  41544. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41545. */
  41546. state: WebXRState;
  41547. private _setState;
  41548. private static _TmpVector;
  41549. /**
  41550. * Fires when the state of the experience helper has changed
  41551. */
  41552. onStateChangedObservable: Observable<WebXRState>;
  41553. /** Session manager used to keep track of xr session */
  41554. sessionManager: WebXRSessionManager;
  41555. private _nonVRCamera;
  41556. private _originalSceneAutoClear;
  41557. private _supported;
  41558. /**
  41559. * Creates the experience helper
  41560. * @param scene the scene to attach the experience helper to
  41561. * @returns a promise for the experience helper
  41562. */
  41563. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41564. /**
  41565. * Creates a WebXRExperienceHelper
  41566. * @param scene The scene the helper should be created in
  41567. */
  41568. private constructor();
  41569. /**
  41570. * Exits XR mode and returns the scene to its original state
  41571. * @returns promise that resolves after xr mode has exited
  41572. */
  41573. exitXRAsync(): Promise<unknown>;
  41574. /**
  41575. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41576. * @param sessionCreationOptions options for the XR session
  41577. * @param referenceSpaceType frame of reference of the XR session
  41578. * @param outputCanvas the output canvas that will be used to enter XR mode
  41579. * @returns promise that resolves after xr mode has entered
  41580. */
  41581. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41582. /**
  41583. * Updates the global position of the camera by moving the camera's container
  41584. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41585. * @param position The desired global position of the camera
  41586. */
  41587. setPositionOfCameraUsingContainer(position: Vector3): void;
  41588. /**
  41589. * Rotates the xr camera by rotating the camera's container around the camera's position
  41590. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41591. * @param rotation the desired quaternion rotation to apply to the camera
  41592. */
  41593. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41594. /**
  41595. * Disposes of the experience helper
  41596. */
  41597. dispose(): void;
  41598. }
  41599. }
  41600. declare module BABYLON {
  41601. /**
  41602. * Button which can be used to enter a different mode of XR
  41603. */
  41604. export class WebXREnterExitUIButton {
  41605. /** button element */
  41606. element: HTMLElement;
  41607. /** XR initialization options for the button */
  41608. sessionMode: XRSessionMode;
  41609. /** Reference space type */
  41610. referenceSpaceType: XRReferenceSpaceType;
  41611. /**
  41612. * Creates a WebXREnterExitUIButton
  41613. * @param element button element
  41614. * @param sessionMode XR initialization session mode
  41615. * @param referenceSpaceType the type of reference space to be used
  41616. */
  41617. constructor(
  41618. /** button element */
  41619. element: HTMLElement,
  41620. /** XR initialization options for the button */
  41621. sessionMode: XRSessionMode,
  41622. /** Reference space type */
  41623. referenceSpaceType: XRReferenceSpaceType);
  41624. /**
  41625. * Overwritable function which can be used to update the button's visuals when the state changes
  41626. * @param activeButton the current active button in the UI
  41627. */
  41628. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41629. }
  41630. /**
  41631. * Options to create the webXR UI
  41632. */
  41633. export class WebXREnterExitUIOptions {
  41634. /**
  41635. * Context to enter xr with
  41636. */
  41637. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41638. /**
  41639. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41640. */
  41641. customButtons?: Array<WebXREnterExitUIButton>;
  41642. }
  41643. /**
  41644. * UI to allow the user to enter/exit XR mode
  41645. */
  41646. export class WebXREnterExitUI implements IDisposable {
  41647. private scene;
  41648. private _overlay;
  41649. private _buttons;
  41650. private _activeButton;
  41651. /**
  41652. * Fired every time the active button is changed.
  41653. *
  41654. * When xr is entered via a button that launches xr that button will be the callback parameter
  41655. *
  41656. * When exiting xr the callback parameter will be null)
  41657. */
  41658. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41659. /**
  41660. * Creates UI to allow the user to enter/exit XR mode
  41661. * @param scene the scene to add the ui to
  41662. * @param helper the xr experience helper to enter/exit xr with
  41663. * @param options options to configure the UI
  41664. * @returns the created ui
  41665. */
  41666. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41667. private constructor();
  41668. private _updateButtons;
  41669. /**
  41670. * Disposes of the object
  41671. */
  41672. dispose(): void;
  41673. }
  41674. }
  41675. declare module BABYLON {
  41676. /**
  41677. * Represents an XR input
  41678. */
  41679. export class WebXRController {
  41680. private scene;
  41681. /** The underlying input source for the controller */
  41682. inputSource: XRInputSource;
  41683. private parentContainer;
  41684. /**
  41685. * 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
  41686. */
  41687. grip?: AbstractMesh;
  41688. /**
  41689. * Pointer which can be used to select objects or attach a visible laser to
  41690. */
  41691. pointer: AbstractMesh;
  41692. /**
  41693. * Event that fires when the controller is removed/disposed
  41694. */
  41695. onDisposeObservable: Observable<{}>;
  41696. private _tmpMatrix;
  41697. private _tmpQuaternion;
  41698. private _tmpVector;
  41699. /**
  41700. * Creates the controller
  41701. * @see https://doc.babylonjs.com/how_to/webxr
  41702. * @param scene the scene which the controller should be associated to
  41703. * @param inputSource the underlying input source for the controller
  41704. * @param parentContainer parent that the controller meshes should be children of
  41705. */
  41706. constructor(scene: Scene,
  41707. /** The underlying input source for the controller */
  41708. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41709. /**
  41710. * Updates the controller pose based on the given XRFrame
  41711. * @param xrFrame xr frame to update the pose with
  41712. * @param referenceSpace reference space to use
  41713. */
  41714. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41715. /**
  41716. * Gets a world space ray coming from the controller
  41717. * @param result the resulting ray
  41718. */
  41719. getWorldPointerRayToRef(result: Ray): void;
  41720. /**
  41721. * Disposes of the object
  41722. */
  41723. dispose(): void;
  41724. }
  41725. }
  41726. declare module BABYLON {
  41727. /**
  41728. * XR input used to track XR inputs such as controllers/rays
  41729. */
  41730. export class WebXRInput implements IDisposable {
  41731. /**
  41732. * Base experience the input listens to
  41733. */
  41734. baseExperience: WebXRExperienceHelper;
  41735. /**
  41736. * XR controllers being tracked
  41737. */
  41738. controllers: Array<WebXRController>;
  41739. private _frameObserver;
  41740. private _stateObserver;
  41741. /**
  41742. * Event when a controller has been connected/added
  41743. */
  41744. onControllerAddedObservable: Observable<WebXRController>;
  41745. /**
  41746. * Event when a controller has been removed/disconnected
  41747. */
  41748. onControllerRemovedObservable: Observable<WebXRController>;
  41749. /**
  41750. * Initializes the WebXRInput
  41751. * @param baseExperience experience helper which the input should be created for
  41752. */
  41753. constructor(
  41754. /**
  41755. * Base experience the input listens to
  41756. */
  41757. baseExperience: WebXRExperienceHelper);
  41758. private _onInputSourcesChange;
  41759. private _addAndRemoveControllers;
  41760. /**
  41761. * Disposes of the object
  41762. */
  41763. dispose(): void;
  41764. }
  41765. }
  41766. declare module BABYLON {
  41767. /**
  41768. * Enables teleportation
  41769. */
  41770. export class WebXRControllerTeleportation {
  41771. private _teleportationFillColor;
  41772. private _teleportationBorderColor;
  41773. private _tmpRay;
  41774. private _tmpVector;
  41775. /**
  41776. * Creates a WebXRControllerTeleportation
  41777. * @param input input manager to add teleportation to
  41778. * @param floorMeshes floormeshes which can be teleported to
  41779. */
  41780. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41781. }
  41782. }
  41783. declare module BABYLON {
  41784. /**
  41785. * Handles pointer input automatically for the pointer of XR controllers
  41786. */
  41787. export class WebXRControllerPointerSelection {
  41788. private static _idCounter;
  41789. private _tmpRay;
  41790. /**
  41791. * Creates a WebXRControllerPointerSelection
  41792. * @param input input manager to setup pointer selection
  41793. */
  41794. constructor(input: WebXRInput);
  41795. private _convertNormalToDirectionOfRay;
  41796. private _updatePointerDistance;
  41797. }
  41798. }
  41799. declare module BABYLON {
  41800. /**
  41801. * Class used to represent data loading progression
  41802. */
  41803. export class SceneLoaderProgressEvent {
  41804. /** defines if data length to load can be evaluated */
  41805. readonly lengthComputable: boolean;
  41806. /** defines the loaded data length */
  41807. readonly loaded: number;
  41808. /** defines the data length to load */
  41809. readonly total: number;
  41810. /**
  41811. * Create a new progress event
  41812. * @param lengthComputable defines if data length to load can be evaluated
  41813. * @param loaded defines the loaded data length
  41814. * @param total defines the data length to load
  41815. */
  41816. constructor(
  41817. /** defines if data length to load can be evaluated */
  41818. lengthComputable: boolean,
  41819. /** defines the loaded data length */
  41820. loaded: number,
  41821. /** defines the data length to load */
  41822. total: number);
  41823. /**
  41824. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41825. * @param event defines the source event
  41826. * @returns a new SceneLoaderProgressEvent
  41827. */
  41828. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41829. }
  41830. /**
  41831. * Interface used by SceneLoader plugins to define supported file extensions
  41832. */
  41833. export interface ISceneLoaderPluginExtensions {
  41834. /**
  41835. * Defines the list of supported extensions
  41836. */
  41837. [extension: string]: {
  41838. isBinary: boolean;
  41839. };
  41840. }
  41841. /**
  41842. * Interface used by SceneLoader plugin factory
  41843. */
  41844. export interface ISceneLoaderPluginFactory {
  41845. /**
  41846. * Defines the name of the factory
  41847. */
  41848. name: string;
  41849. /**
  41850. * Function called to create a new plugin
  41851. * @return the new plugin
  41852. */
  41853. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41854. /**
  41855. * Boolean indicating if the plugin can direct load specific data
  41856. */
  41857. canDirectLoad?: (data: string) => boolean;
  41858. }
  41859. /**
  41860. * Interface used to define a SceneLoader plugin
  41861. */
  41862. export interface ISceneLoaderPlugin {
  41863. /**
  41864. * The friendly name of this plugin.
  41865. */
  41866. name: string;
  41867. /**
  41868. * The file extensions supported by this plugin.
  41869. */
  41870. extensions: string | ISceneLoaderPluginExtensions;
  41871. /**
  41872. * Import meshes into a scene.
  41873. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41874. * @param scene The scene to import into
  41875. * @param data The data to import
  41876. * @param rootUrl The root url for scene and resources
  41877. * @param meshes The meshes array to import into
  41878. * @param particleSystems The particle systems array to import into
  41879. * @param skeletons The skeletons array to import into
  41880. * @param onError The callback when import fails
  41881. * @returns True if successful or false otherwise
  41882. */
  41883. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41884. /**
  41885. * Load into a scene.
  41886. * @param scene The scene to load into
  41887. * @param data The data to import
  41888. * @param rootUrl The root url for scene and resources
  41889. * @param onError The callback when import fails
  41890. * @returns true if successful or false otherwise
  41891. */
  41892. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41893. /**
  41894. * The callback that returns true if the data can be directly loaded.
  41895. */
  41896. canDirectLoad?: (data: string) => boolean;
  41897. /**
  41898. * The callback that allows custom handling of the root url based on the response url.
  41899. */
  41900. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41901. /**
  41902. * Load into an asset container.
  41903. * @param scene The scene to load into
  41904. * @param data The data to import
  41905. * @param rootUrl The root url for scene and resources
  41906. * @param onError The callback when import fails
  41907. * @returns The loaded asset container
  41908. */
  41909. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41910. }
  41911. /**
  41912. * Interface used to define an async SceneLoader plugin
  41913. */
  41914. export interface ISceneLoaderPluginAsync {
  41915. /**
  41916. * The friendly name of this plugin.
  41917. */
  41918. name: string;
  41919. /**
  41920. * The file extensions supported by this plugin.
  41921. */
  41922. extensions: string | ISceneLoaderPluginExtensions;
  41923. /**
  41924. * Import meshes into a scene.
  41925. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41926. * @param scene The scene to import into
  41927. * @param data The data to import
  41928. * @param rootUrl The root url for scene and resources
  41929. * @param onProgress The callback when the load progresses
  41930. * @param fileName Defines the name of the file to load
  41931. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41932. */
  41933. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41934. meshes: AbstractMesh[];
  41935. particleSystems: IParticleSystem[];
  41936. skeletons: Skeleton[];
  41937. animationGroups: AnimationGroup[];
  41938. }>;
  41939. /**
  41940. * Load into a scene.
  41941. * @param scene The scene to load into
  41942. * @param data The data to import
  41943. * @param rootUrl The root url for scene and resources
  41944. * @param onProgress The callback when the load progresses
  41945. * @param fileName Defines the name of the file to load
  41946. * @returns Nothing
  41947. */
  41948. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41949. /**
  41950. * The callback that returns true if the data can be directly loaded.
  41951. */
  41952. canDirectLoad?: (data: string) => boolean;
  41953. /**
  41954. * The callback that allows custom handling of the root url based on the response url.
  41955. */
  41956. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41957. /**
  41958. * Load into an asset container.
  41959. * @param scene The scene to load into
  41960. * @param data The data to import
  41961. * @param rootUrl The root url for scene and resources
  41962. * @param onProgress The callback when the load progresses
  41963. * @param fileName Defines the name of the file to load
  41964. * @returns The loaded asset container
  41965. */
  41966. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41967. }
  41968. /**
  41969. * Class used to load scene from various file formats using registered plugins
  41970. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41971. */
  41972. export class SceneLoader {
  41973. /**
  41974. * No logging while loading
  41975. */
  41976. static readonly NO_LOGGING: number;
  41977. /**
  41978. * Minimal logging while loading
  41979. */
  41980. static readonly MINIMAL_LOGGING: number;
  41981. /**
  41982. * Summary logging while loading
  41983. */
  41984. static readonly SUMMARY_LOGGING: number;
  41985. /**
  41986. * Detailled logging while loading
  41987. */
  41988. static readonly DETAILED_LOGGING: number;
  41989. /**
  41990. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41991. */
  41992. static ForceFullSceneLoadingForIncremental: boolean;
  41993. /**
  41994. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41995. */
  41996. static ShowLoadingScreen: boolean;
  41997. /**
  41998. * Defines the current logging level (while loading the scene)
  41999. * @ignorenaming
  42000. */
  42001. static loggingLevel: number;
  42002. /**
  42003. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42004. */
  42005. static CleanBoneMatrixWeights: boolean;
  42006. /**
  42007. * Event raised when a plugin is used to load a scene
  42008. */
  42009. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42010. private static _registeredPlugins;
  42011. private static _getDefaultPlugin;
  42012. private static _getPluginForExtension;
  42013. private static _getPluginForDirectLoad;
  42014. private static _getPluginForFilename;
  42015. private static _getDirectLoad;
  42016. private static _loadData;
  42017. private static _getFileInfo;
  42018. /**
  42019. * Gets a plugin that can load the given extension
  42020. * @param extension defines the extension to load
  42021. * @returns a plugin or null if none works
  42022. */
  42023. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42024. /**
  42025. * Gets a boolean indicating that the given extension can be loaded
  42026. * @param extension defines the extension to load
  42027. * @returns true if the extension is supported
  42028. */
  42029. static IsPluginForExtensionAvailable(extension: string): boolean;
  42030. /**
  42031. * Adds a new plugin to the list of registered plugins
  42032. * @param plugin defines the plugin to add
  42033. */
  42034. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42035. /**
  42036. * Import meshes into a scene
  42037. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42038. * @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)
  42039. * @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)
  42040. * @param scene the instance of BABYLON.Scene to append to
  42041. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42042. * @param onProgress a callback with a progress event for each file being loaded
  42043. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42044. * @param pluginExtension the extension used to determine the plugin
  42045. * @returns The loaded plugin
  42046. */
  42047. 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>;
  42048. /**
  42049. * Import meshes into a scene
  42050. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42051. * @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)
  42052. * @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)
  42053. * @param scene the instance of BABYLON.Scene to append to
  42054. * @param onProgress a callback with a progress event for each file being loaded
  42055. * @param pluginExtension the extension used to determine the plugin
  42056. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42057. */
  42058. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42059. meshes: AbstractMesh[];
  42060. particleSystems: IParticleSystem[];
  42061. skeletons: Skeleton[];
  42062. animationGroups: AnimationGroup[];
  42063. }>;
  42064. /**
  42065. * Load a scene
  42066. * @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)
  42067. * @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)
  42068. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42069. * @param onSuccess a callback with the scene when import succeeds
  42070. * @param onProgress a callback with a progress event for each file being loaded
  42071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42072. * @param pluginExtension the extension used to determine the plugin
  42073. * @returns The loaded plugin
  42074. */
  42075. 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>;
  42076. /**
  42077. * Load a scene
  42078. * @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)
  42079. * @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)
  42080. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42081. * @param onProgress a callback with a progress event for each file being loaded
  42082. * @param pluginExtension the extension used to determine the plugin
  42083. * @returns The loaded scene
  42084. */
  42085. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42086. /**
  42087. * Append a scene
  42088. * @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)
  42089. * @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)
  42090. * @param scene is the instance of BABYLON.Scene to append to
  42091. * @param onSuccess a callback with the scene when import succeeds
  42092. * @param onProgress a callback with a progress event for each file being loaded
  42093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42094. * @param pluginExtension the extension used to determine the plugin
  42095. * @returns The loaded plugin
  42096. */
  42097. 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>;
  42098. /**
  42099. * Append a scene
  42100. * @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)
  42101. * @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)
  42102. * @param scene is the instance of BABYLON.Scene to append to
  42103. * @param onProgress a callback with a progress event for each file being loaded
  42104. * @param pluginExtension the extension used to determine the plugin
  42105. * @returns The given scene
  42106. */
  42107. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42108. /**
  42109. * Load a scene into an asset container
  42110. * @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)
  42111. * @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)
  42112. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42113. * @param onSuccess a callback with the scene when import succeeds
  42114. * @param onProgress a callback with a progress event for each file being loaded
  42115. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42116. * @param pluginExtension the extension used to determine the plugin
  42117. * @returns The loaded plugin
  42118. */
  42119. 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>;
  42120. /**
  42121. * Load a scene into an asset container
  42122. * @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)
  42123. * @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)
  42124. * @param scene is the instance of Scene to append to
  42125. * @param onProgress a callback with a progress event for each file being loaded
  42126. * @param pluginExtension the extension used to determine the plugin
  42127. * @returns The loaded asset container
  42128. */
  42129. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * Generic Controller
  42135. */
  42136. export class GenericController extends WebVRController {
  42137. /**
  42138. * Base Url for the controller model.
  42139. */
  42140. static readonly MODEL_BASE_URL: string;
  42141. /**
  42142. * File name for the controller model.
  42143. */
  42144. static readonly MODEL_FILENAME: string;
  42145. /**
  42146. * Creates a new GenericController from a gamepad
  42147. * @param vrGamepad the gamepad that the controller should be created from
  42148. */
  42149. constructor(vrGamepad: any);
  42150. /**
  42151. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42152. * @param scene scene in which to add meshes
  42153. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42154. */
  42155. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42156. /**
  42157. * Called once for each button that changed state since the last frame
  42158. * @param buttonIdx Which button index changed
  42159. * @param state New state of the button
  42160. * @param changes Which properties on the state changed since last frame
  42161. */
  42162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42163. }
  42164. }
  42165. declare module BABYLON {
  42166. /**
  42167. * Defines the WindowsMotionController object that the state of the windows motion controller
  42168. */
  42169. export class WindowsMotionController extends WebVRController {
  42170. /**
  42171. * The base url used to load the left and right controller models
  42172. */
  42173. static MODEL_BASE_URL: string;
  42174. /**
  42175. * The name of the left controller model file
  42176. */
  42177. static MODEL_LEFT_FILENAME: string;
  42178. /**
  42179. * The name of the right controller model file
  42180. */
  42181. static MODEL_RIGHT_FILENAME: string;
  42182. /**
  42183. * The controller name prefix for this controller type
  42184. */
  42185. static readonly GAMEPAD_ID_PREFIX: string;
  42186. /**
  42187. * The controller id pattern for this controller type
  42188. */
  42189. private static readonly GAMEPAD_ID_PATTERN;
  42190. private _loadedMeshInfo;
  42191. private readonly _mapping;
  42192. /**
  42193. * Fired when the trackpad on this controller is clicked
  42194. */
  42195. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42196. /**
  42197. * Fired when the trackpad on this controller is modified
  42198. */
  42199. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42200. /**
  42201. * The current x and y values of this controller's trackpad
  42202. */
  42203. trackpad: StickValues;
  42204. /**
  42205. * Creates a new WindowsMotionController from a gamepad
  42206. * @param vrGamepad the gamepad that the controller should be created from
  42207. */
  42208. constructor(vrGamepad: any);
  42209. /**
  42210. * Fired when the trigger on this controller is modified
  42211. */
  42212. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42213. /**
  42214. * Fired when the menu button on this controller is modified
  42215. */
  42216. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42217. /**
  42218. * Fired when the grip button on this controller is modified
  42219. */
  42220. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42221. /**
  42222. * Fired when the thumbstick button on this controller is modified
  42223. */
  42224. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42225. /**
  42226. * Fired when the touchpad button on this controller is modified
  42227. */
  42228. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42229. /**
  42230. * Fired when the touchpad values on this controller are modified
  42231. */
  42232. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42233. private _updateTrackpad;
  42234. /**
  42235. * Called once per frame by the engine.
  42236. */
  42237. update(): void;
  42238. /**
  42239. * Called once for each button that changed state since the last frame
  42240. * @param buttonIdx Which button index changed
  42241. * @param state New state of the button
  42242. * @param changes Which properties on the state changed since last frame
  42243. */
  42244. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42245. /**
  42246. * Moves the buttons on the controller mesh based on their current state
  42247. * @param buttonName the name of the button to move
  42248. * @param buttonValue the value of the button which determines the buttons new position
  42249. */
  42250. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42251. /**
  42252. * Moves the axis on the controller mesh based on its current state
  42253. * @param axis the index of the axis
  42254. * @param axisValue the value of the axis which determines the meshes new position
  42255. * @hidden
  42256. */
  42257. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42258. /**
  42259. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42260. * @param scene scene in which to add meshes
  42261. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42262. */
  42263. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42264. /**
  42265. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42266. * can be transformed by button presses and axes values, based on this._mapping.
  42267. *
  42268. * @param scene scene in which the meshes exist
  42269. * @param meshes list of meshes that make up the controller model to process
  42270. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42271. */
  42272. private processModel;
  42273. private createMeshInfo;
  42274. /**
  42275. * Gets the ray of the controller in the direction the controller is pointing
  42276. * @param length the length the resulting ray should be
  42277. * @returns a ray in the direction the controller is pointing
  42278. */
  42279. getForwardRay(length?: number): Ray;
  42280. /**
  42281. * Disposes of the controller
  42282. */
  42283. dispose(): void;
  42284. }
  42285. }
  42286. declare module BABYLON {
  42287. /**
  42288. * Oculus Touch Controller
  42289. */
  42290. export class OculusTouchController extends WebVRController {
  42291. /**
  42292. * Base Url for the controller model.
  42293. */
  42294. static MODEL_BASE_URL: string;
  42295. /**
  42296. * File name for the left controller model.
  42297. */
  42298. static MODEL_LEFT_FILENAME: string;
  42299. /**
  42300. * File name for the right controller model.
  42301. */
  42302. static MODEL_RIGHT_FILENAME: string;
  42303. /**
  42304. * Base Url for the Quest controller model.
  42305. */
  42306. static QUEST_MODEL_BASE_URL: string;
  42307. /**
  42308. * @hidden
  42309. * If the controllers are running on a device that needs the updated Quest controller models
  42310. */
  42311. static _IsQuest: boolean;
  42312. /**
  42313. * Fired when the secondary trigger on this controller is modified
  42314. */
  42315. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42316. /**
  42317. * Fired when the thumb rest on this controller is modified
  42318. */
  42319. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42320. /**
  42321. * Creates a new OculusTouchController from a gamepad
  42322. * @param vrGamepad the gamepad that the controller should be created from
  42323. */
  42324. constructor(vrGamepad: any);
  42325. /**
  42326. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42327. * @param scene scene in which to add meshes
  42328. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42329. */
  42330. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42331. /**
  42332. * Fired when the A button on this controller is modified
  42333. */
  42334. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42335. /**
  42336. * Fired when the B button on this controller is modified
  42337. */
  42338. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42339. /**
  42340. * Fired when the X button on this controller is modified
  42341. */
  42342. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42343. /**
  42344. * Fired when the Y button on this controller is modified
  42345. */
  42346. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42347. /**
  42348. * Called once for each button that changed state since the last frame
  42349. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42350. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42351. * 2) secondary trigger (same)
  42352. * 3) A (right) X (left), touch, pressed = value
  42353. * 4) B / Y
  42354. * 5) thumb rest
  42355. * @param buttonIdx Which button index changed
  42356. * @param state New state of the button
  42357. * @param changes Which properties on the state changed since last frame
  42358. */
  42359. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42360. }
  42361. }
  42362. declare module BABYLON {
  42363. /**
  42364. * Vive Controller
  42365. */
  42366. export class ViveController extends WebVRController {
  42367. /**
  42368. * Base Url for the controller model.
  42369. */
  42370. static MODEL_BASE_URL: string;
  42371. /**
  42372. * File name for the controller model.
  42373. */
  42374. static MODEL_FILENAME: string;
  42375. /**
  42376. * Creates a new ViveController from a gamepad
  42377. * @param vrGamepad the gamepad that the controller should be created from
  42378. */
  42379. constructor(vrGamepad: any);
  42380. /**
  42381. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42382. * @param scene scene in which to add meshes
  42383. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42384. */
  42385. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42386. /**
  42387. * Fired when the left button on this controller is modified
  42388. */
  42389. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42390. /**
  42391. * Fired when the right button on this controller is modified
  42392. */
  42393. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42394. /**
  42395. * Fired when the menu button on this controller is modified
  42396. */
  42397. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42398. /**
  42399. * Called once for each button that changed state since the last frame
  42400. * Vive mapping:
  42401. * 0: touchpad
  42402. * 1: trigger
  42403. * 2: left AND right buttons
  42404. * 3: menu button
  42405. * @param buttonIdx Which button index changed
  42406. * @param state New state of the button
  42407. * @param changes Which properties on the state changed since last frame
  42408. */
  42409. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42410. }
  42411. }
  42412. declare module BABYLON {
  42413. /**
  42414. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42415. */
  42416. export class WebXRControllerModelLoader {
  42417. /**
  42418. * Creates the WebXRControllerModelLoader
  42419. * @param input xr input that creates the controllers
  42420. */
  42421. constructor(input: WebXRInput);
  42422. }
  42423. }
  42424. declare module BABYLON {
  42425. /**
  42426. * Contains an array of blocks representing the octree
  42427. */
  42428. export interface IOctreeContainer<T> {
  42429. /**
  42430. * Blocks within the octree
  42431. */
  42432. blocks: Array<OctreeBlock<T>>;
  42433. }
  42434. /**
  42435. * Class used to store a cell in an octree
  42436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42437. */
  42438. export class OctreeBlock<T> {
  42439. /**
  42440. * Gets the content of the current block
  42441. */
  42442. entries: T[];
  42443. /**
  42444. * Gets the list of block children
  42445. */
  42446. blocks: Array<OctreeBlock<T>>;
  42447. private _depth;
  42448. private _maxDepth;
  42449. private _capacity;
  42450. private _minPoint;
  42451. private _maxPoint;
  42452. private _boundingVectors;
  42453. private _creationFunc;
  42454. /**
  42455. * Creates a new block
  42456. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42457. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42458. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42459. * @param depth defines the current depth of this block in the octree
  42460. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42461. * @param creationFunc defines a callback to call when an element is added to the block
  42462. */
  42463. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42464. /**
  42465. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42466. */
  42467. readonly capacity: number;
  42468. /**
  42469. * Gets the minimum vector (in world space) of the block's bounding box
  42470. */
  42471. readonly minPoint: Vector3;
  42472. /**
  42473. * Gets the maximum vector (in world space) of the block's bounding box
  42474. */
  42475. readonly maxPoint: Vector3;
  42476. /**
  42477. * Add a new element to this block
  42478. * @param entry defines the element to add
  42479. */
  42480. addEntry(entry: T): void;
  42481. /**
  42482. * Remove an element from this block
  42483. * @param entry defines the element to remove
  42484. */
  42485. removeEntry(entry: T): void;
  42486. /**
  42487. * Add an array of elements to this block
  42488. * @param entries defines the array of elements to add
  42489. */
  42490. addEntries(entries: T[]): void;
  42491. /**
  42492. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42493. * @param frustumPlanes defines the frustum planes to test
  42494. * @param selection defines the array to store current content if selection is positive
  42495. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42496. */
  42497. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42498. /**
  42499. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42500. * @param sphereCenter defines the bounding sphere center
  42501. * @param sphereRadius defines the bounding sphere radius
  42502. * @param selection defines the array to store current content if selection is positive
  42503. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42504. */
  42505. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42506. /**
  42507. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42508. * @param ray defines the ray to test with
  42509. * @param selection defines the array to store current content if selection is positive
  42510. */
  42511. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42512. /**
  42513. * Subdivide the content into child blocks (this block will then be empty)
  42514. */
  42515. createInnerBlocks(): void;
  42516. /**
  42517. * @hidden
  42518. */
  42519. 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;
  42520. }
  42521. }
  42522. declare module BABYLON {
  42523. /**
  42524. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42525. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42526. */
  42527. export class Octree<T> {
  42528. /** 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.) */
  42529. maxDepth: number;
  42530. /**
  42531. * Blocks within the octree containing objects
  42532. */
  42533. blocks: Array<OctreeBlock<T>>;
  42534. /**
  42535. * Content stored in the octree
  42536. */
  42537. dynamicContent: T[];
  42538. private _maxBlockCapacity;
  42539. private _selectionContent;
  42540. private _creationFunc;
  42541. /**
  42542. * Creates a octree
  42543. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42544. * @param creationFunc function to be used to instatiate the octree
  42545. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42546. * @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.)
  42547. */
  42548. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42549. /** 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.) */
  42550. maxDepth?: number);
  42551. /**
  42552. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42553. * @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);
  42554. * @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);
  42555. * @param entries meshes to be added to the octree blocks
  42556. */
  42557. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42558. /**
  42559. * Adds a mesh to the octree
  42560. * @param entry Mesh to add to the octree
  42561. */
  42562. addMesh(entry: T): void;
  42563. /**
  42564. * Remove an element from the octree
  42565. * @param entry defines the element to remove
  42566. */
  42567. removeMesh(entry: T): void;
  42568. /**
  42569. * Selects an array of meshes within the frustum
  42570. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42571. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42572. * @returns array of meshes within the frustum
  42573. */
  42574. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42575. /**
  42576. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42577. * @param sphereCenter defines the bounding sphere center
  42578. * @param sphereRadius defines the bounding sphere radius
  42579. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42580. * @returns an array of objects that intersect the sphere
  42581. */
  42582. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42583. /**
  42584. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42585. * @param ray defines the ray to test with
  42586. * @returns array of intersected objects
  42587. */
  42588. intersectsRay(ray: Ray): SmartArray<T>;
  42589. /**
  42590. * Adds a mesh into the octree block if it intersects the block
  42591. */
  42592. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42593. /**
  42594. * Adds a submesh into the octree block if it intersects the block
  42595. */
  42596. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42597. }
  42598. }
  42599. declare module BABYLON {
  42600. interface Scene {
  42601. /**
  42602. * @hidden
  42603. * Backing Filed
  42604. */
  42605. _selectionOctree: Octree<AbstractMesh>;
  42606. /**
  42607. * Gets the octree used to boost mesh selection (picking)
  42608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42609. */
  42610. selectionOctree: Octree<AbstractMesh>;
  42611. /**
  42612. * Creates or updates the octree used to boost selection (picking)
  42613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42614. * @param maxCapacity defines the maximum capacity per leaf
  42615. * @param maxDepth defines the maximum depth of the octree
  42616. * @returns an octree of AbstractMesh
  42617. */
  42618. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42619. }
  42620. interface AbstractMesh {
  42621. /**
  42622. * @hidden
  42623. * Backing Field
  42624. */
  42625. _submeshesOctree: Octree<SubMesh>;
  42626. /**
  42627. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42628. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42629. * @param maxCapacity defines the maximum size of each block (64 by default)
  42630. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42631. * @returns the new octree
  42632. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42634. */
  42635. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42636. }
  42637. /**
  42638. * Defines the octree scene component responsible to manage any octrees
  42639. * in a given scene.
  42640. */
  42641. export class OctreeSceneComponent {
  42642. /**
  42643. * The component name help to identify the component in the list of scene components.
  42644. */
  42645. readonly name: string;
  42646. /**
  42647. * The scene the component belongs to.
  42648. */
  42649. scene: Scene;
  42650. /**
  42651. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42652. */
  42653. readonly checksIsEnabled: boolean;
  42654. /**
  42655. * Creates a new instance of the component for the given scene
  42656. * @param scene Defines the scene to register the component in
  42657. */
  42658. constructor(scene: Scene);
  42659. /**
  42660. * Registers the component in a given scene
  42661. */
  42662. register(): void;
  42663. /**
  42664. * Return the list of active meshes
  42665. * @returns the list of active meshes
  42666. */
  42667. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42668. /**
  42669. * Return the list of active sub meshes
  42670. * @param mesh The mesh to get the candidates sub meshes from
  42671. * @returns the list of active sub meshes
  42672. */
  42673. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42674. private _tempRay;
  42675. /**
  42676. * Return the list of sub meshes intersecting with a given local ray
  42677. * @param mesh defines the mesh to find the submesh for
  42678. * @param localRay defines the ray in local space
  42679. * @returns the list of intersecting sub meshes
  42680. */
  42681. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42682. /**
  42683. * Return the list of sub meshes colliding with a collider
  42684. * @param mesh defines the mesh to find the submesh for
  42685. * @param collider defines the collider to evaluate the collision against
  42686. * @returns the list of colliding sub meshes
  42687. */
  42688. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42689. /**
  42690. * Rebuilds the elements related to this component in case of
  42691. * context lost for instance.
  42692. */
  42693. rebuild(): void;
  42694. /**
  42695. * Disposes the component and the associated ressources.
  42696. */
  42697. dispose(): void;
  42698. }
  42699. }
  42700. declare module BABYLON {
  42701. /**
  42702. * Renders a layer on top of an existing scene
  42703. */
  42704. export class UtilityLayerRenderer implements IDisposable {
  42705. /** the original scene that will be rendered on top of */
  42706. originalScene: Scene;
  42707. private _pointerCaptures;
  42708. private _lastPointerEvents;
  42709. private static _DefaultUtilityLayer;
  42710. private static _DefaultKeepDepthUtilityLayer;
  42711. private _sharedGizmoLight;
  42712. private _renderCamera;
  42713. /**
  42714. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42715. * @returns the camera that is used when rendering the utility layer
  42716. */
  42717. getRenderCamera(): Nullable<Camera>;
  42718. /**
  42719. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42720. * @param cam the camera that should be used when rendering the utility layer
  42721. */
  42722. setRenderCamera(cam: Nullable<Camera>): void;
  42723. /**
  42724. * @hidden
  42725. * Light which used by gizmos to get light shading
  42726. */
  42727. _getSharedGizmoLight(): HemisphericLight;
  42728. /**
  42729. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42730. */
  42731. pickUtilitySceneFirst: boolean;
  42732. /**
  42733. * 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)
  42734. */
  42735. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42736. /**
  42737. * 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)
  42738. */
  42739. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42740. /**
  42741. * The scene that is rendered on top of the original scene
  42742. */
  42743. utilityLayerScene: Scene;
  42744. /**
  42745. * If the utility layer should automatically be rendered on top of existing scene
  42746. */
  42747. shouldRender: boolean;
  42748. /**
  42749. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42750. */
  42751. onlyCheckPointerDownEvents: boolean;
  42752. /**
  42753. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42754. */
  42755. processAllEvents: boolean;
  42756. /**
  42757. * Observable raised when the pointer move from the utility layer scene to the main scene
  42758. */
  42759. onPointerOutObservable: Observable<number>;
  42760. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42761. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42762. private _afterRenderObserver;
  42763. private _sceneDisposeObserver;
  42764. private _originalPointerObserver;
  42765. /**
  42766. * Instantiates a UtilityLayerRenderer
  42767. * @param originalScene the original scene that will be rendered on top of
  42768. * @param handleEvents boolean indicating if the utility layer should handle events
  42769. */
  42770. constructor(
  42771. /** the original scene that will be rendered on top of */
  42772. originalScene: Scene, handleEvents?: boolean);
  42773. private _notifyObservers;
  42774. /**
  42775. * Renders the utility layers scene on top of the original scene
  42776. */
  42777. render(): void;
  42778. /**
  42779. * Disposes of the renderer
  42780. */
  42781. dispose(): void;
  42782. private _updateCamera;
  42783. }
  42784. }
  42785. declare module BABYLON {
  42786. /**
  42787. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42788. */
  42789. export class Gizmo implements IDisposable {
  42790. /** The utility layer the gizmo will be added to */
  42791. gizmoLayer: UtilityLayerRenderer;
  42792. /**
  42793. * The root mesh of the gizmo
  42794. */
  42795. _rootMesh: Mesh;
  42796. private _attachedMesh;
  42797. /**
  42798. * Ratio for the scale of the gizmo (Default: 1)
  42799. */
  42800. scaleRatio: number;
  42801. /**
  42802. * If a custom mesh has been set (Default: false)
  42803. */
  42804. protected _customMeshSet: boolean;
  42805. /**
  42806. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42807. * * When set, interactions will be enabled
  42808. */
  42809. attachedMesh: Nullable<AbstractMesh>;
  42810. /**
  42811. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42812. * @param mesh The mesh to replace the default mesh of the gizmo
  42813. */
  42814. setCustomMesh(mesh: Mesh): void;
  42815. /**
  42816. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42817. */
  42818. updateGizmoRotationToMatchAttachedMesh: boolean;
  42819. /**
  42820. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42821. */
  42822. updateGizmoPositionToMatchAttachedMesh: boolean;
  42823. /**
  42824. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42825. */
  42826. updateScale: boolean;
  42827. protected _interactionsEnabled: boolean;
  42828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42829. private _beforeRenderObserver;
  42830. private _tempVector;
  42831. /**
  42832. * Creates a gizmo
  42833. * @param gizmoLayer The utility layer the gizmo will be added to
  42834. */
  42835. constructor(
  42836. /** The utility layer the gizmo will be added to */
  42837. gizmoLayer?: UtilityLayerRenderer);
  42838. /**
  42839. * Updates the gizmo to match the attached mesh's position/rotation
  42840. */
  42841. protected _update(): void;
  42842. /**
  42843. * Disposes of the gizmo
  42844. */
  42845. dispose(): void;
  42846. }
  42847. }
  42848. declare module BABYLON {
  42849. /**
  42850. * Single plane drag gizmo
  42851. */
  42852. export class PlaneDragGizmo extends Gizmo {
  42853. /**
  42854. * Drag behavior responsible for the gizmos dragging interactions
  42855. */
  42856. dragBehavior: PointerDragBehavior;
  42857. private _pointerObserver;
  42858. /**
  42859. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42860. */
  42861. snapDistance: number;
  42862. /**
  42863. * Event that fires each time the gizmo snaps to a new location.
  42864. * * snapDistance is the the change in distance
  42865. */
  42866. onSnapObservable: Observable<{
  42867. snapDistance: number;
  42868. }>;
  42869. private _plane;
  42870. private _coloredMaterial;
  42871. private _hoverMaterial;
  42872. private _isEnabled;
  42873. private _parent;
  42874. /** @hidden */
  42875. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42876. /** @hidden */
  42877. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42878. /**
  42879. * Creates a PlaneDragGizmo
  42880. * @param gizmoLayer The utility layer the gizmo will be added to
  42881. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42882. * @param color The color of the gizmo
  42883. */
  42884. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42885. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42886. /**
  42887. * If the gizmo is enabled
  42888. */
  42889. isEnabled: boolean;
  42890. /**
  42891. * Disposes of the gizmo
  42892. */
  42893. dispose(): void;
  42894. }
  42895. }
  42896. declare module BABYLON {
  42897. /**
  42898. * Gizmo that enables dragging a mesh along 3 axis
  42899. */
  42900. export class PositionGizmo extends Gizmo {
  42901. /**
  42902. * Internal gizmo used for interactions on the x axis
  42903. */
  42904. xGizmo: AxisDragGizmo;
  42905. /**
  42906. * Internal gizmo used for interactions on the y axis
  42907. */
  42908. yGizmo: AxisDragGizmo;
  42909. /**
  42910. * Internal gizmo used for interactions on the z axis
  42911. */
  42912. zGizmo: AxisDragGizmo;
  42913. /**
  42914. * Internal gizmo used for interactions on the yz plane
  42915. */
  42916. xPlaneGizmo: PlaneDragGizmo;
  42917. /**
  42918. * Internal gizmo used for interactions on the xz plane
  42919. */
  42920. yPlaneGizmo: PlaneDragGizmo;
  42921. /**
  42922. * Internal gizmo used for interactions on the xy plane
  42923. */
  42924. zPlaneGizmo: PlaneDragGizmo;
  42925. /**
  42926. * private variables
  42927. */
  42928. private _meshAttached;
  42929. private _updateGizmoRotationToMatchAttachedMesh;
  42930. private _snapDistance;
  42931. private _scaleRatio;
  42932. /** Fires an event when any of it's sub gizmos are dragged */
  42933. onDragStartObservable: Observable<unknown>;
  42934. /** Fires an event when any of it's sub gizmos are released from dragging */
  42935. onDragEndObservable: Observable<unknown>;
  42936. /**
  42937. * If set to true, planar drag is enabled
  42938. */
  42939. private _planarGizmoEnabled;
  42940. attachedMesh: Nullable<AbstractMesh>;
  42941. /**
  42942. * Creates a PositionGizmo
  42943. * @param gizmoLayer The utility layer the gizmo will be added to
  42944. */
  42945. constructor(gizmoLayer?: UtilityLayerRenderer);
  42946. /**
  42947. * If the planar drag gizmo is enabled
  42948. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42949. */
  42950. planarGizmoEnabled: boolean;
  42951. updateGizmoRotationToMatchAttachedMesh: boolean;
  42952. /**
  42953. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42954. */
  42955. snapDistance: number;
  42956. /**
  42957. * Ratio for the scale of the gizmo (Default: 1)
  42958. */
  42959. scaleRatio: number;
  42960. /**
  42961. * Disposes of the gizmo
  42962. */
  42963. dispose(): void;
  42964. /**
  42965. * CustomMeshes are not supported by this gizmo
  42966. * @param mesh The mesh to replace the default mesh of the gizmo
  42967. */
  42968. setCustomMesh(mesh: Mesh): void;
  42969. }
  42970. }
  42971. declare module BABYLON {
  42972. /**
  42973. * Single axis drag gizmo
  42974. */
  42975. export class AxisDragGizmo extends Gizmo {
  42976. /**
  42977. * Drag behavior responsible for the gizmos dragging interactions
  42978. */
  42979. dragBehavior: PointerDragBehavior;
  42980. private _pointerObserver;
  42981. /**
  42982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42983. */
  42984. snapDistance: number;
  42985. /**
  42986. * Event that fires each time the gizmo snaps to a new location.
  42987. * * snapDistance is the the change in distance
  42988. */
  42989. onSnapObservable: Observable<{
  42990. snapDistance: number;
  42991. }>;
  42992. private _isEnabled;
  42993. private _parent;
  42994. private _arrow;
  42995. private _coloredMaterial;
  42996. private _hoverMaterial;
  42997. /** @hidden */
  42998. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42999. /** @hidden */
  43000. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43001. /**
  43002. * Creates an AxisDragGizmo
  43003. * @param gizmoLayer The utility layer the gizmo will be added to
  43004. * @param dragAxis The axis which the gizmo will be able to drag on
  43005. * @param color The color of the gizmo
  43006. */
  43007. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43008. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43009. /**
  43010. * If the gizmo is enabled
  43011. */
  43012. isEnabled: boolean;
  43013. /**
  43014. * Disposes of the gizmo
  43015. */
  43016. dispose(): void;
  43017. }
  43018. }
  43019. declare module BABYLON.Debug {
  43020. /**
  43021. * The Axes viewer will show 3 axes in a specific point in space
  43022. */
  43023. export class AxesViewer {
  43024. private _xAxis;
  43025. private _yAxis;
  43026. private _zAxis;
  43027. private _scaleLinesFactor;
  43028. private _instanced;
  43029. /**
  43030. * Gets the hosting scene
  43031. */
  43032. scene: Scene;
  43033. /**
  43034. * Gets or sets a number used to scale line length
  43035. */
  43036. scaleLines: number;
  43037. /** Gets the node hierarchy used to render x-axis */
  43038. readonly xAxis: TransformNode;
  43039. /** Gets the node hierarchy used to render y-axis */
  43040. readonly yAxis: TransformNode;
  43041. /** Gets the node hierarchy used to render z-axis */
  43042. readonly zAxis: TransformNode;
  43043. /**
  43044. * Creates a new AxesViewer
  43045. * @param scene defines the hosting scene
  43046. * @param scaleLines defines a number used to scale line length (1 by default)
  43047. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43048. * @param xAxis defines the node hierarchy used to render the x-axis
  43049. * @param yAxis defines the node hierarchy used to render the y-axis
  43050. * @param zAxis defines the node hierarchy used to render the z-axis
  43051. */
  43052. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43053. /**
  43054. * Force the viewer to update
  43055. * @param position defines the position of the viewer
  43056. * @param xaxis defines the x axis of the viewer
  43057. * @param yaxis defines the y axis of the viewer
  43058. * @param zaxis defines the z axis of the viewer
  43059. */
  43060. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43061. /**
  43062. * Creates an instance of this axes viewer.
  43063. * @returns a new axes viewer with instanced meshes
  43064. */
  43065. createInstance(): AxesViewer;
  43066. /** Releases resources */
  43067. dispose(): void;
  43068. private static _SetRenderingGroupId;
  43069. }
  43070. }
  43071. declare module BABYLON.Debug {
  43072. /**
  43073. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43074. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43075. */
  43076. export class BoneAxesViewer extends AxesViewer {
  43077. /**
  43078. * Gets or sets the target mesh where to display the axes viewer
  43079. */
  43080. mesh: Nullable<Mesh>;
  43081. /**
  43082. * Gets or sets the target bone where to display the axes viewer
  43083. */
  43084. bone: Nullable<Bone>;
  43085. /** Gets current position */
  43086. pos: Vector3;
  43087. /** Gets direction of X axis */
  43088. xaxis: Vector3;
  43089. /** Gets direction of Y axis */
  43090. yaxis: Vector3;
  43091. /** Gets direction of Z axis */
  43092. zaxis: Vector3;
  43093. /**
  43094. * Creates a new BoneAxesViewer
  43095. * @param scene defines the hosting scene
  43096. * @param bone defines the target bone
  43097. * @param mesh defines the target mesh
  43098. * @param scaleLines defines a scaling factor for line length (1 by default)
  43099. */
  43100. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43101. /**
  43102. * Force the viewer to update
  43103. */
  43104. update(): void;
  43105. /** Releases resources */
  43106. dispose(): void;
  43107. }
  43108. }
  43109. declare module BABYLON {
  43110. /**
  43111. * Interface used to define scene explorer extensibility option
  43112. */
  43113. export interface IExplorerExtensibilityOption {
  43114. /**
  43115. * Define the option label
  43116. */
  43117. label: string;
  43118. /**
  43119. * Defines the action to execute on click
  43120. */
  43121. action: (entity: any) => void;
  43122. }
  43123. /**
  43124. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43125. */
  43126. export interface IExplorerExtensibilityGroup {
  43127. /**
  43128. * Defines a predicate to test if a given type mut be extended
  43129. */
  43130. predicate: (entity: any) => boolean;
  43131. /**
  43132. * Gets the list of options added to a type
  43133. */
  43134. entries: IExplorerExtensibilityOption[];
  43135. }
  43136. /**
  43137. * Interface used to define the options to use to create the Inspector
  43138. */
  43139. export interface IInspectorOptions {
  43140. /**
  43141. * Display in overlay mode (default: false)
  43142. */
  43143. overlay?: boolean;
  43144. /**
  43145. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43146. */
  43147. globalRoot?: HTMLElement;
  43148. /**
  43149. * Display the Scene explorer
  43150. */
  43151. showExplorer?: boolean;
  43152. /**
  43153. * Display the property inspector
  43154. */
  43155. showInspector?: boolean;
  43156. /**
  43157. * Display in embed mode (both panes on the right)
  43158. */
  43159. embedMode?: boolean;
  43160. /**
  43161. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43162. */
  43163. handleResize?: boolean;
  43164. /**
  43165. * Allow the panes to popup (default: true)
  43166. */
  43167. enablePopup?: boolean;
  43168. /**
  43169. * Allow the panes to be closed by users (default: true)
  43170. */
  43171. enableClose?: boolean;
  43172. /**
  43173. * Optional list of extensibility entries
  43174. */
  43175. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43176. /**
  43177. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43178. */
  43179. inspectorURL?: string;
  43180. }
  43181. interface Scene {
  43182. /**
  43183. * @hidden
  43184. * Backing field
  43185. */
  43186. _debugLayer: DebugLayer;
  43187. /**
  43188. * Gets the debug layer (aka Inspector) associated with the scene
  43189. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43190. */
  43191. debugLayer: DebugLayer;
  43192. }
  43193. /**
  43194. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43195. * what is happening in your scene
  43196. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43197. */
  43198. export class DebugLayer {
  43199. /**
  43200. * Define the url to get the inspector script from.
  43201. * By default it uses the babylonjs CDN.
  43202. * @ignoreNaming
  43203. */
  43204. static InspectorURL: string;
  43205. private _scene;
  43206. private BJSINSPECTOR;
  43207. private _onPropertyChangedObservable?;
  43208. /**
  43209. * Observable triggered when a property is changed through the inspector.
  43210. */
  43211. readonly onPropertyChangedObservable: any;
  43212. /**
  43213. * Instantiates a new debug layer.
  43214. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43215. * what is happening in your scene
  43216. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43217. * @param scene Defines the scene to inspect
  43218. */
  43219. constructor(scene: Scene);
  43220. /** Creates the inspector window. */
  43221. private _createInspector;
  43222. /**
  43223. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43224. * @param entity defines the entity to select
  43225. * @param lineContainerTitle defines the specific block to highlight
  43226. */
  43227. select(entity: any, lineContainerTitle?: string): void;
  43228. /** Get the inspector from bundle or global */
  43229. private _getGlobalInspector;
  43230. /**
  43231. * Get if the inspector is visible or not.
  43232. * @returns true if visible otherwise, false
  43233. */
  43234. isVisible(): boolean;
  43235. /**
  43236. * Hide the inspector and close its window.
  43237. */
  43238. hide(): void;
  43239. /**
  43240. * Launch the debugLayer.
  43241. * @param config Define the configuration of the inspector
  43242. * @return a promise fulfilled when the debug layer is visible
  43243. */
  43244. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43245. }
  43246. }
  43247. declare module BABYLON {
  43248. /**
  43249. * Class containing static functions to help procedurally build meshes
  43250. */
  43251. export class BoxBuilder {
  43252. /**
  43253. * Creates a box mesh
  43254. * * The parameter `size` sets the size (float) of each box side (default 1)
  43255. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43256. * * 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)
  43257. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43259. * * 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
  43260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43261. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43262. * @param name defines the name of the mesh
  43263. * @param options defines the options used to create the mesh
  43264. * @param scene defines the hosting scene
  43265. * @returns the box mesh
  43266. */
  43267. static CreateBox(name: string, options: {
  43268. size?: number;
  43269. width?: number;
  43270. height?: number;
  43271. depth?: number;
  43272. faceUV?: Vector4[];
  43273. faceColors?: Color4[];
  43274. sideOrientation?: number;
  43275. frontUVs?: Vector4;
  43276. backUVs?: Vector4;
  43277. wrap?: boolean;
  43278. topBaseAt?: number;
  43279. bottomBaseAt?: number;
  43280. updatable?: boolean;
  43281. }, scene?: Nullable<Scene>): Mesh;
  43282. }
  43283. }
  43284. declare module BABYLON {
  43285. /**
  43286. * Class containing static functions to help procedurally build meshes
  43287. */
  43288. export class SphereBuilder {
  43289. /**
  43290. * Creates a sphere mesh
  43291. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43292. * * 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`)
  43293. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43294. * * 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
  43295. * * 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)
  43296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43297. * * 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
  43298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43299. * @param name defines the name of the mesh
  43300. * @param options defines the options used to create the mesh
  43301. * @param scene defines the hosting scene
  43302. * @returns the sphere mesh
  43303. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43304. */
  43305. static CreateSphere(name: string, options: {
  43306. segments?: number;
  43307. diameter?: number;
  43308. diameterX?: number;
  43309. diameterY?: number;
  43310. diameterZ?: number;
  43311. arc?: number;
  43312. slice?: number;
  43313. sideOrientation?: number;
  43314. frontUVs?: Vector4;
  43315. backUVs?: Vector4;
  43316. updatable?: boolean;
  43317. }, scene?: Nullable<Scene>): Mesh;
  43318. }
  43319. }
  43320. declare module BABYLON.Debug {
  43321. /**
  43322. * Used to show the physics impostor around the specific mesh
  43323. */
  43324. export class PhysicsViewer {
  43325. /** @hidden */
  43326. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43327. /** @hidden */
  43328. protected _meshes: Array<Nullable<AbstractMesh>>;
  43329. /** @hidden */
  43330. protected _scene: Nullable<Scene>;
  43331. /** @hidden */
  43332. protected _numMeshes: number;
  43333. /** @hidden */
  43334. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43335. private _renderFunction;
  43336. private _utilityLayer;
  43337. private _debugBoxMesh;
  43338. private _debugSphereMesh;
  43339. private _debugCylinderMesh;
  43340. private _debugMaterial;
  43341. private _debugMeshMeshes;
  43342. /**
  43343. * Creates a new PhysicsViewer
  43344. * @param scene defines the hosting scene
  43345. */
  43346. constructor(scene: Scene);
  43347. /** @hidden */
  43348. protected _updateDebugMeshes(): void;
  43349. /**
  43350. * Renders a specified physic impostor
  43351. * @param impostor defines the impostor to render
  43352. * @param targetMesh defines the mesh represented by the impostor
  43353. * @returns the new debug mesh used to render the impostor
  43354. */
  43355. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43356. /**
  43357. * Hides a specified physic impostor
  43358. * @param impostor defines the impostor to hide
  43359. */
  43360. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43361. private _getDebugMaterial;
  43362. private _getDebugBoxMesh;
  43363. private _getDebugSphereMesh;
  43364. private _getDebugCylinderMesh;
  43365. private _getDebugMeshMesh;
  43366. private _getDebugMesh;
  43367. /** Releases all resources */
  43368. dispose(): void;
  43369. }
  43370. }
  43371. declare module BABYLON {
  43372. /**
  43373. * Class containing static functions to help procedurally build meshes
  43374. */
  43375. export class LinesBuilder {
  43376. /**
  43377. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43378. * * 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
  43379. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43380. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43381. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43382. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43383. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43384. * * 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
  43385. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43388. * @param name defines the name of the new line system
  43389. * @param options defines the options used to create the line system
  43390. * @param scene defines the hosting scene
  43391. * @returns a new line system mesh
  43392. */
  43393. static CreateLineSystem(name: string, options: {
  43394. lines: Vector3[][];
  43395. updatable?: boolean;
  43396. instance?: Nullable<LinesMesh>;
  43397. colors?: Nullable<Color4[][]>;
  43398. useVertexAlpha?: boolean;
  43399. }, scene: Nullable<Scene>): LinesMesh;
  43400. /**
  43401. * Creates a line mesh
  43402. * 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
  43403. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43404. * * The parameter `points` is an array successive Vector3
  43405. * * 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
  43406. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43407. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43408. * * When updating an instance, remember that only point positions can change, not the number of points
  43409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43411. * @param name defines the name of the new line system
  43412. * @param options defines the options used to create the line system
  43413. * @param scene defines the hosting scene
  43414. * @returns a new line mesh
  43415. */
  43416. static CreateLines(name: string, options: {
  43417. points: Vector3[];
  43418. updatable?: boolean;
  43419. instance?: Nullable<LinesMesh>;
  43420. colors?: Color4[];
  43421. useVertexAlpha?: boolean;
  43422. }, scene?: Nullable<Scene>): LinesMesh;
  43423. /**
  43424. * Creates a dashed line mesh
  43425. * * 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
  43426. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43427. * * The parameter `points` is an array successive Vector3
  43428. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43429. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43430. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43431. * * 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
  43432. * * When updating an instance, remember that only point positions can change, not the number of points
  43433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43434. * @param name defines the name of the mesh
  43435. * @param options defines the options used to create the mesh
  43436. * @param scene defines the hosting scene
  43437. * @returns the dashed line mesh
  43438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43439. */
  43440. static CreateDashedLines(name: string, options: {
  43441. points: Vector3[];
  43442. dashSize?: number;
  43443. gapSize?: number;
  43444. dashNb?: number;
  43445. updatable?: boolean;
  43446. instance?: LinesMesh;
  43447. }, scene?: Nullable<Scene>): LinesMesh;
  43448. }
  43449. }
  43450. declare module BABYLON {
  43451. /**
  43452. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43453. * in order to better appreciate the issue one might have.
  43454. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43455. */
  43456. export class RayHelper {
  43457. /**
  43458. * Defines the ray we are currently tryin to visualize.
  43459. */
  43460. ray: Nullable<Ray>;
  43461. private _renderPoints;
  43462. private _renderLine;
  43463. private _renderFunction;
  43464. private _scene;
  43465. private _updateToMeshFunction;
  43466. private _attachedToMesh;
  43467. private _meshSpaceDirection;
  43468. private _meshSpaceOrigin;
  43469. /**
  43470. * Helper function to create a colored helper in a scene in one line.
  43471. * @param ray Defines the ray we are currently tryin to visualize
  43472. * @param scene Defines the scene the ray is used in
  43473. * @param color Defines the color we want to see the ray in
  43474. * @returns The newly created ray helper.
  43475. */
  43476. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43477. /**
  43478. * Instantiate a new ray helper.
  43479. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43480. * in order to better appreciate the issue one might have.
  43481. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43482. * @param ray Defines the ray we are currently tryin to visualize
  43483. */
  43484. constructor(ray: Ray);
  43485. /**
  43486. * Shows the ray we are willing to debug.
  43487. * @param scene Defines the scene the ray needs to be rendered in
  43488. * @param color Defines the color the ray needs to be rendered in
  43489. */
  43490. show(scene: Scene, color?: Color3): void;
  43491. /**
  43492. * Hides the ray we are debugging.
  43493. */
  43494. hide(): void;
  43495. private _render;
  43496. /**
  43497. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43498. * @param mesh Defines the mesh we want the helper attached to
  43499. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43500. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43501. * @param length Defines the length of the ray
  43502. */
  43503. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43504. /**
  43505. * Detach the ray helper from the mesh it has previously been attached to.
  43506. */
  43507. detachFromMesh(): void;
  43508. private _updateToMesh;
  43509. /**
  43510. * Dispose the helper and release its associated resources.
  43511. */
  43512. dispose(): void;
  43513. }
  43514. }
  43515. declare module BABYLON.Debug {
  43516. /**
  43517. * Class used to render a debug view of a given skeleton
  43518. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43519. */
  43520. export class SkeletonViewer {
  43521. /** defines the skeleton to render */
  43522. skeleton: Skeleton;
  43523. /** defines the mesh attached to the skeleton */
  43524. mesh: AbstractMesh;
  43525. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43526. autoUpdateBonesMatrices: boolean;
  43527. /** defines the rendering group id to use with the viewer */
  43528. renderingGroupId: number;
  43529. /** Gets or sets the color used to render the skeleton */
  43530. color: Color3;
  43531. private _scene;
  43532. private _debugLines;
  43533. private _debugMesh;
  43534. private _isEnabled;
  43535. private _renderFunction;
  43536. private _utilityLayer;
  43537. /**
  43538. * Returns the mesh used to render the bones
  43539. */
  43540. readonly debugMesh: Nullable<LinesMesh>;
  43541. /**
  43542. * Creates a new SkeletonViewer
  43543. * @param skeleton defines the skeleton to render
  43544. * @param mesh defines the mesh attached to the skeleton
  43545. * @param scene defines the hosting scene
  43546. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43547. * @param renderingGroupId defines the rendering group id to use with the viewer
  43548. */
  43549. constructor(
  43550. /** defines the skeleton to render */
  43551. skeleton: Skeleton,
  43552. /** defines the mesh attached to the skeleton */
  43553. mesh: AbstractMesh, scene: Scene,
  43554. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43555. autoUpdateBonesMatrices?: boolean,
  43556. /** defines the rendering group id to use with the viewer */
  43557. renderingGroupId?: number);
  43558. /** Gets or sets a boolean indicating if the viewer is enabled */
  43559. isEnabled: boolean;
  43560. private _getBonePosition;
  43561. private _getLinesForBonesWithLength;
  43562. private _getLinesForBonesNoLength;
  43563. /** Update the viewer to sync with current skeleton state */
  43564. update(): void;
  43565. /** Release associated resources */
  43566. dispose(): void;
  43567. }
  43568. }
  43569. declare module BABYLON {
  43570. /**
  43571. * Options to create the null engine
  43572. */
  43573. export class NullEngineOptions {
  43574. /**
  43575. * Render width (Default: 512)
  43576. */
  43577. renderWidth: number;
  43578. /**
  43579. * Render height (Default: 256)
  43580. */
  43581. renderHeight: number;
  43582. /**
  43583. * Texture size (Default: 512)
  43584. */
  43585. textureSize: number;
  43586. /**
  43587. * If delta time between frames should be constant
  43588. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43589. */
  43590. deterministicLockstep: boolean;
  43591. /**
  43592. * Maximum about of steps between frames (Default: 4)
  43593. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43594. */
  43595. lockstepMaxSteps: number;
  43596. }
  43597. /**
  43598. * The null engine class provides support for headless version of babylon.js.
  43599. * This can be used in server side scenario or for testing purposes
  43600. */
  43601. export class NullEngine extends Engine {
  43602. private _options;
  43603. /**
  43604. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43605. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43606. * @returns true if engine is in deterministic lock step mode
  43607. */
  43608. isDeterministicLockStep(): boolean;
  43609. /**
  43610. * Gets the max steps when engine is running in deterministic lock step
  43611. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43612. * @returns the max steps
  43613. */
  43614. getLockstepMaxSteps(): number;
  43615. /**
  43616. * Gets the current hardware scaling level.
  43617. * By default the hardware scaling level is computed from the window device ratio.
  43618. * 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.
  43619. * @returns a number indicating the current hardware scaling level
  43620. */
  43621. getHardwareScalingLevel(): number;
  43622. constructor(options?: NullEngineOptions);
  43623. /**
  43624. * Creates a vertex buffer
  43625. * @param vertices the data for the vertex buffer
  43626. * @returns the new WebGL static buffer
  43627. */
  43628. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43629. /**
  43630. * Creates a new index buffer
  43631. * @param indices defines the content of the index buffer
  43632. * @param updatable defines if the index buffer must be updatable
  43633. * @returns a new webGL buffer
  43634. */
  43635. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43636. /**
  43637. * Clear the current render buffer or the current render target (if any is set up)
  43638. * @param color defines the color to use
  43639. * @param backBuffer defines if the back buffer must be cleared
  43640. * @param depth defines if the depth buffer must be cleared
  43641. * @param stencil defines if the stencil buffer must be cleared
  43642. */
  43643. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43644. /**
  43645. * Gets the current render width
  43646. * @param useScreen defines if screen size must be used (or the current render target if any)
  43647. * @returns a number defining the current render width
  43648. */
  43649. getRenderWidth(useScreen?: boolean): number;
  43650. /**
  43651. * Gets the current render height
  43652. * @param useScreen defines if screen size must be used (or the current render target if any)
  43653. * @returns a number defining the current render height
  43654. */
  43655. getRenderHeight(useScreen?: boolean): number;
  43656. /**
  43657. * Set the WebGL's viewport
  43658. * @param viewport defines the viewport element to be used
  43659. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43660. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43661. */
  43662. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43663. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43664. /**
  43665. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43666. * @param pipelineContext defines the pipeline context to use
  43667. * @param uniformsNames defines the list of uniform names
  43668. * @returns an array of webGL uniform locations
  43669. */
  43670. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43671. /**
  43672. * Gets the lsit of active attributes for a given webGL program
  43673. * @param pipelineContext defines the pipeline context to use
  43674. * @param attributesNames defines the list of attribute names to get
  43675. * @returns an array of indices indicating the offset of each attribute
  43676. */
  43677. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43678. /**
  43679. * Binds an effect to the webGL context
  43680. * @param effect defines the effect to bind
  43681. */
  43682. bindSamplers(effect: Effect): void;
  43683. /**
  43684. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43685. * @param effect defines the effect to activate
  43686. */
  43687. enableEffect(effect: Effect): void;
  43688. /**
  43689. * Set various states to the webGL context
  43690. * @param culling defines backface culling state
  43691. * @param zOffset defines the value to apply to zOffset (0 by default)
  43692. * @param force defines if states must be applied even if cache is up to date
  43693. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43694. */
  43695. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43696. /**
  43697. * Set the value of an uniform to an array of int32
  43698. * @param uniform defines the webGL uniform location where to store the value
  43699. * @param array defines the array of int32 to store
  43700. */
  43701. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43702. /**
  43703. * Set the value of an uniform to an array of int32 (stored as vec2)
  43704. * @param uniform defines the webGL uniform location where to store the value
  43705. * @param array defines the array of int32 to store
  43706. */
  43707. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43708. /**
  43709. * Set the value of an uniform to an array of int32 (stored as vec3)
  43710. * @param uniform defines the webGL uniform location where to store the value
  43711. * @param array defines the array of int32 to store
  43712. */
  43713. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43714. /**
  43715. * Set the value of an uniform to an array of int32 (stored as vec4)
  43716. * @param uniform defines the webGL uniform location where to store the value
  43717. * @param array defines the array of int32 to store
  43718. */
  43719. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43720. /**
  43721. * Set the value of an uniform to an array of float32
  43722. * @param uniform defines the webGL uniform location where to store the value
  43723. * @param array defines the array of float32 to store
  43724. */
  43725. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43726. /**
  43727. * Set the value of an uniform to an array of float32 (stored as vec2)
  43728. * @param uniform defines the webGL uniform location where to store the value
  43729. * @param array defines the array of float32 to store
  43730. */
  43731. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43732. /**
  43733. * Set the value of an uniform to an array of float32 (stored as vec3)
  43734. * @param uniform defines the webGL uniform location where to store the value
  43735. * @param array defines the array of float32 to store
  43736. */
  43737. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43738. /**
  43739. * Set the value of an uniform to an array of float32 (stored as vec4)
  43740. * @param uniform defines the webGL uniform location where to store the value
  43741. * @param array defines the array of float32 to store
  43742. */
  43743. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43744. /**
  43745. * Set the value of an uniform to an array of number
  43746. * @param uniform defines the webGL uniform location where to store the value
  43747. * @param array defines the array of number to store
  43748. */
  43749. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43750. /**
  43751. * Set the value of an uniform to an array of number (stored as vec2)
  43752. * @param uniform defines the webGL uniform location where to store the value
  43753. * @param array defines the array of number to store
  43754. */
  43755. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43756. /**
  43757. * Set the value of an uniform to an array of number (stored as vec3)
  43758. * @param uniform defines the webGL uniform location where to store the value
  43759. * @param array defines the array of number to store
  43760. */
  43761. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43762. /**
  43763. * Set the value of an uniform to an array of number (stored as vec4)
  43764. * @param uniform defines the webGL uniform location where to store the value
  43765. * @param array defines the array of number to store
  43766. */
  43767. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43768. /**
  43769. * Set the value of an uniform to an array of float32 (stored as matrices)
  43770. * @param uniform defines the webGL uniform location where to store the value
  43771. * @param matrices defines the array of float32 to store
  43772. */
  43773. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43774. /**
  43775. * Set the value of an uniform to a matrix (3x3)
  43776. * @param uniform defines the webGL uniform location where to store the value
  43777. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43778. */
  43779. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43780. /**
  43781. * Set the value of an uniform to a matrix (2x2)
  43782. * @param uniform defines the webGL uniform location where to store the value
  43783. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43784. */
  43785. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43786. /**
  43787. * Set the value of an uniform to a number (float)
  43788. * @param uniform defines the webGL uniform location where to store the value
  43789. * @param value defines the float number to store
  43790. */
  43791. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43792. /**
  43793. * Set the value of an uniform to a vec2
  43794. * @param uniform defines the webGL uniform location where to store the value
  43795. * @param x defines the 1st component of the value
  43796. * @param y defines the 2nd component of the value
  43797. */
  43798. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43799. /**
  43800. * Set the value of an uniform to a vec3
  43801. * @param uniform defines the webGL uniform location where to store the value
  43802. * @param x defines the 1st component of the value
  43803. * @param y defines the 2nd component of the value
  43804. * @param z defines the 3rd component of the value
  43805. */
  43806. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43807. /**
  43808. * Set the value of an uniform to a boolean
  43809. * @param uniform defines the webGL uniform location where to store the value
  43810. * @param bool defines the boolean to store
  43811. */
  43812. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43813. /**
  43814. * Set the value of an uniform to a vec4
  43815. * @param uniform defines the webGL uniform location where to store the value
  43816. * @param x defines the 1st component of the value
  43817. * @param y defines the 2nd component of the value
  43818. * @param z defines the 3rd component of the value
  43819. * @param w defines the 4th component of the value
  43820. */
  43821. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43822. /**
  43823. * Sets the current alpha mode
  43824. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43825. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43826. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43827. */
  43828. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43829. /**
  43830. * Bind webGl buffers directly to the webGL context
  43831. * @param vertexBuffers defines the vertex buffer to bind
  43832. * @param indexBuffer defines the index buffer to bind
  43833. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43834. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43835. * @param effect defines the effect associated with the vertex buffer
  43836. */
  43837. bindBuffers(vertexBuffers: {
  43838. [key: string]: VertexBuffer;
  43839. }, indexBuffer: DataBuffer, effect: Effect): void;
  43840. /**
  43841. * Force the entire cache to be cleared
  43842. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43843. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43844. */
  43845. wipeCaches(bruteForce?: boolean): void;
  43846. /**
  43847. * Send a draw order
  43848. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43849. * @param indexStart defines the starting index
  43850. * @param indexCount defines the number of index to draw
  43851. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43852. */
  43853. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43854. /**
  43855. * Draw a list of indexed primitives
  43856. * @param fillMode defines the primitive to use
  43857. * @param indexStart defines the starting index
  43858. * @param indexCount defines the number of index to draw
  43859. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43860. */
  43861. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43862. /**
  43863. * Draw a list of unindexed primitives
  43864. * @param fillMode defines the primitive to use
  43865. * @param verticesStart defines the index of first vertex to draw
  43866. * @param verticesCount defines the count of vertices to draw
  43867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43868. */
  43869. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43870. /** @hidden */
  43871. _createTexture(): WebGLTexture;
  43872. /** @hidden */
  43873. _releaseTexture(texture: InternalTexture): void;
  43874. /**
  43875. * Usually called from Texture.ts.
  43876. * Passed information to create a WebGLTexture
  43877. * @param urlArg defines a value which contains one of the following:
  43878. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43879. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43880. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43881. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43882. * @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)
  43883. * @param scene needed for loading to the correct scene
  43884. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43885. * @param onLoad optional callback to be called upon successful completion
  43886. * @param onError optional callback to be called upon failure
  43887. * @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
  43888. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43889. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43890. * @param forcedExtension defines the extension to use to pick the right loader
  43891. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43892. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43893. */
  43894. 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;
  43895. /**
  43896. * Creates a new render target texture
  43897. * @param size defines the size of the texture
  43898. * @param options defines the options used to create the texture
  43899. * @returns a new render target texture stored in an InternalTexture
  43900. */
  43901. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43902. /**
  43903. * Update the sampling mode of a given texture
  43904. * @param samplingMode defines the required sampling mode
  43905. * @param texture defines the texture to update
  43906. */
  43907. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43908. /**
  43909. * Binds the frame buffer to the specified texture.
  43910. * @param texture The texture to render to or null for the default canvas
  43911. * @param faceIndex The face of the texture to render to in case of cube texture
  43912. * @param requiredWidth The width of the target to render to
  43913. * @param requiredHeight The height of the target to render to
  43914. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43915. * @param depthStencilTexture The depth stencil texture to use to render
  43916. * @param lodLevel defines le lod level to bind to the frame buffer
  43917. */
  43918. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43919. /**
  43920. * Unbind the current render target texture from the webGL context
  43921. * @param texture defines the render target texture to unbind
  43922. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43923. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43924. */
  43925. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43926. /**
  43927. * Creates a dynamic vertex buffer
  43928. * @param vertices the data for the dynamic vertex buffer
  43929. * @returns the new WebGL dynamic buffer
  43930. */
  43931. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43932. /**
  43933. * Update the content of a dynamic texture
  43934. * @param texture defines the texture to update
  43935. * @param canvas defines the canvas containing the source
  43936. * @param invertY defines if data must be stored with Y axis inverted
  43937. * @param premulAlpha defines if alpha is stored as premultiplied
  43938. * @param format defines the format of the data
  43939. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43940. */
  43941. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43942. /**
  43943. * Gets a boolean indicating if all created effects are ready
  43944. * @returns true if all effects are ready
  43945. */
  43946. areAllEffectsReady(): boolean;
  43947. /**
  43948. * @hidden
  43949. * Get the current error code of the webGL context
  43950. * @returns the error code
  43951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43952. */
  43953. getError(): number;
  43954. /** @hidden */
  43955. _getUnpackAlignement(): number;
  43956. /** @hidden */
  43957. _unpackFlipY(value: boolean): void;
  43958. /**
  43959. * Update a dynamic index buffer
  43960. * @param indexBuffer defines the target index buffer
  43961. * @param indices defines the data to update
  43962. * @param offset defines the offset in the target index buffer where update should start
  43963. */
  43964. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43965. /**
  43966. * Updates a dynamic vertex buffer.
  43967. * @param vertexBuffer the vertex buffer to update
  43968. * @param vertices the data used to update the vertex buffer
  43969. * @param byteOffset the byte offset of the data (optional)
  43970. * @param byteLength the byte length of the data (optional)
  43971. */
  43972. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43973. /** @hidden */
  43974. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43975. /** @hidden */
  43976. _bindTexture(channel: number, texture: InternalTexture): void;
  43977. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43978. /**
  43979. * 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
  43980. */
  43981. releaseEffects(): void;
  43982. displayLoadingUI(): void;
  43983. hideLoadingUI(): void;
  43984. /** @hidden */
  43985. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43986. /** @hidden */
  43987. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43988. /** @hidden */
  43989. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43990. /** @hidden */
  43991. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43992. }
  43993. }
  43994. declare module BABYLON {
  43995. /** @hidden */
  43996. export class _OcclusionDataStorage {
  43997. /** @hidden */
  43998. occlusionInternalRetryCounter: number;
  43999. /** @hidden */
  44000. isOcclusionQueryInProgress: boolean;
  44001. /** @hidden */
  44002. isOccluded: boolean;
  44003. /** @hidden */
  44004. occlusionRetryCount: number;
  44005. /** @hidden */
  44006. occlusionType: number;
  44007. /** @hidden */
  44008. occlusionQueryAlgorithmType: number;
  44009. }
  44010. interface Engine {
  44011. /**
  44012. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44013. * @return the new query
  44014. */
  44015. createQuery(): WebGLQuery;
  44016. /**
  44017. * Delete and release a webGL query
  44018. * @param query defines the query to delete
  44019. * @return the current engine
  44020. */
  44021. deleteQuery(query: WebGLQuery): Engine;
  44022. /**
  44023. * Check if a given query has resolved and got its value
  44024. * @param query defines the query to check
  44025. * @returns true if the query got its value
  44026. */
  44027. isQueryResultAvailable(query: WebGLQuery): boolean;
  44028. /**
  44029. * Gets the value of a given query
  44030. * @param query defines the query to check
  44031. * @returns the value of the query
  44032. */
  44033. getQueryResult(query: WebGLQuery): number;
  44034. /**
  44035. * Initiates an occlusion query
  44036. * @param algorithmType defines the algorithm to use
  44037. * @param query defines the query to use
  44038. * @returns the current engine
  44039. * @see http://doc.babylonjs.com/features/occlusionquery
  44040. */
  44041. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44042. /**
  44043. * Ends an occlusion query
  44044. * @see http://doc.babylonjs.com/features/occlusionquery
  44045. * @param algorithmType defines the algorithm to use
  44046. * @returns the current engine
  44047. */
  44048. endOcclusionQuery(algorithmType: number): Engine;
  44049. /**
  44050. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44051. * Please note that only one query can be issued at a time
  44052. * @returns a time token used to track the time span
  44053. */
  44054. startTimeQuery(): Nullable<_TimeToken>;
  44055. /**
  44056. * Ends a time query
  44057. * @param token defines the token used to measure the time span
  44058. * @returns the time spent (in ns)
  44059. */
  44060. endTimeQuery(token: _TimeToken): int;
  44061. /** @hidden */
  44062. _currentNonTimestampToken: Nullable<_TimeToken>;
  44063. /** @hidden */
  44064. _createTimeQuery(): WebGLQuery;
  44065. /** @hidden */
  44066. _deleteTimeQuery(query: WebGLQuery): void;
  44067. /** @hidden */
  44068. _getGlAlgorithmType(algorithmType: number): number;
  44069. /** @hidden */
  44070. _getTimeQueryResult(query: WebGLQuery): any;
  44071. /** @hidden */
  44072. _getTimeQueryAvailability(query: WebGLQuery): any;
  44073. }
  44074. interface AbstractMesh {
  44075. /**
  44076. * Backing filed
  44077. * @hidden
  44078. */
  44079. __occlusionDataStorage: _OcclusionDataStorage;
  44080. /**
  44081. * Access property
  44082. * @hidden
  44083. */
  44084. _occlusionDataStorage: _OcclusionDataStorage;
  44085. /**
  44086. * 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.
  44087. * The default value is -1 which means don't break the query and wait till the result
  44088. * @see http://doc.babylonjs.com/features/occlusionquery
  44089. */
  44090. occlusionRetryCount: number;
  44091. /**
  44092. * 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:
  44093. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44094. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44095. * * 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.
  44096. * @see http://doc.babylonjs.com/features/occlusionquery
  44097. */
  44098. occlusionType: number;
  44099. /**
  44100. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44101. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44102. * * 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.
  44103. * @see http://doc.babylonjs.com/features/occlusionquery
  44104. */
  44105. occlusionQueryAlgorithmType: number;
  44106. /**
  44107. * 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
  44108. * @see http://doc.babylonjs.com/features/occlusionquery
  44109. */
  44110. isOccluded: boolean;
  44111. /**
  44112. * Flag to check the progress status of the query
  44113. * @see http://doc.babylonjs.com/features/occlusionquery
  44114. */
  44115. isOcclusionQueryInProgress: boolean;
  44116. }
  44117. }
  44118. declare module BABYLON {
  44119. /** @hidden */
  44120. export var _forceTransformFeedbackToBundle: boolean;
  44121. interface Engine {
  44122. /**
  44123. * Creates a webGL transform feedback object
  44124. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44125. * @returns the webGL transform feedback object
  44126. */
  44127. createTransformFeedback(): WebGLTransformFeedback;
  44128. /**
  44129. * Delete a webGL transform feedback object
  44130. * @param value defines the webGL transform feedback object to delete
  44131. */
  44132. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44133. /**
  44134. * Bind a webGL transform feedback object to the webgl context
  44135. * @param value defines the webGL transform feedback object to bind
  44136. */
  44137. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44138. /**
  44139. * Begins a transform feedback operation
  44140. * @param usePoints defines if points or triangles must be used
  44141. */
  44142. beginTransformFeedback(usePoints: boolean): void;
  44143. /**
  44144. * Ends a transform feedback operation
  44145. */
  44146. endTransformFeedback(): void;
  44147. /**
  44148. * Specify the varyings to use with transform feedback
  44149. * @param program defines the associated webGL program
  44150. * @param value defines the list of strings representing the varying names
  44151. */
  44152. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44153. /**
  44154. * Bind a webGL buffer for a transform feedback operation
  44155. * @param value defines the webGL buffer to bind
  44156. */
  44157. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44158. }
  44159. }
  44160. declare module BABYLON {
  44161. /**
  44162. * Creation options of the multi render target texture.
  44163. */
  44164. export interface IMultiRenderTargetOptions {
  44165. /**
  44166. * Define if the texture needs to create mip maps after render.
  44167. */
  44168. generateMipMaps?: boolean;
  44169. /**
  44170. * Define the types of all the draw buffers we want to create
  44171. */
  44172. types?: number[];
  44173. /**
  44174. * Define the sampling modes of all the draw buffers we want to create
  44175. */
  44176. samplingModes?: number[];
  44177. /**
  44178. * Define if a depth buffer is required
  44179. */
  44180. generateDepthBuffer?: boolean;
  44181. /**
  44182. * Define if a stencil buffer is required
  44183. */
  44184. generateStencilBuffer?: boolean;
  44185. /**
  44186. * Define if a depth texture is required instead of a depth buffer
  44187. */
  44188. generateDepthTexture?: boolean;
  44189. /**
  44190. * Define the number of desired draw buffers
  44191. */
  44192. textureCount?: number;
  44193. /**
  44194. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44195. */
  44196. doNotChangeAspectRatio?: boolean;
  44197. /**
  44198. * Define the default type of the buffers we are creating
  44199. */
  44200. defaultType?: number;
  44201. }
  44202. /**
  44203. * A multi render target, like a render target provides the ability to render to a texture.
  44204. * Unlike the render target, it can render to several draw buffers in one draw.
  44205. * This is specially interesting in deferred rendering or for any effects requiring more than
  44206. * just one color from a single pass.
  44207. */
  44208. export class MultiRenderTarget extends RenderTargetTexture {
  44209. private _internalTextures;
  44210. private _textures;
  44211. private _multiRenderTargetOptions;
  44212. /**
  44213. * Get if draw buffers are currently supported by the used hardware and browser.
  44214. */
  44215. readonly isSupported: boolean;
  44216. /**
  44217. * Get the list of textures generated by the multi render target.
  44218. */
  44219. readonly textures: Texture[];
  44220. /**
  44221. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44222. */
  44223. readonly depthTexture: Texture;
  44224. /**
  44225. * Set the wrapping mode on U of all the textures we are rendering to.
  44226. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44227. */
  44228. wrapU: number;
  44229. /**
  44230. * Set the wrapping mode on V of all the textures we are rendering to.
  44231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44232. */
  44233. wrapV: number;
  44234. /**
  44235. * Instantiate a new multi render target texture.
  44236. * A multi render target, like a render target provides the ability to render to a texture.
  44237. * Unlike the render target, it can render to several draw buffers in one draw.
  44238. * This is specially interesting in deferred rendering or for any effects requiring more than
  44239. * just one color from a single pass.
  44240. * @param name Define the name of the texture
  44241. * @param size Define the size of the buffers to render to
  44242. * @param count Define the number of target we are rendering into
  44243. * @param scene Define the scene the texture belongs to
  44244. * @param options Define the options used to create the multi render target
  44245. */
  44246. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44247. /** @hidden */
  44248. _rebuild(): void;
  44249. private _createInternalTextures;
  44250. private _createTextures;
  44251. /**
  44252. * Define the number of samples used if MSAA is enabled.
  44253. */
  44254. samples: number;
  44255. /**
  44256. * Resize all the textures in the multi render target.
  44257. * Be carrefull as it will recreate all the data in the new texture.
  44258. * @param size Define the new size
  44259. */
  44260. resize(size: any): void;
  44261. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44262. /**
  44263. * Dispose the render targets and their associated resources
  44264. */
  44265. dispose(): void;
  44266. /**
  44267. * Release all the underlying texture used as draw buffers.
  44268. */
  44269. releaseInternalTextures(): void;
  44270. }
  44271. }
  44272. declare module BABYLON {
  44273. interface ThinEngine {
  44274. /**
  44275. * Unbind a list of render target textures from the webGL context
  44276. * This is used only when drawBuffer extension or webGL2 are active
  44277. * @param textures defines the render target textures to unbind
  44278. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44279. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44280. */
  44281. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44282. /**
  44283. * Create a multi render target texture
  44284. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44285. * @param size defines the size of the texture
  44286. * @param options defines the creation options
  44287. * @returns the cube texture as an InternalTexture
  44288. */
  44289. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44290. /**
  44291. * Update the sample count for a given multiple render target texture
  44292. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44293. * @param textures defines the textures to update
  44294. * @param samples defines the sample count to set
  44295. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44296. */
  44297. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44298. }
  44299. }
  44300. declare module BABYLON {
  44301. /** @hidden */
  44302. export var rgbdEncodePixelShader: {
  44303. name: string;
  44304. shader: string;
  44305. };
  44306. }
  44307. declare module BABYLON {
  44308. /** @hidden */
  44309. export var rgbdDecodePixelShader: {
  44310. name: string;
  44311. shader: string;
  44312. };
  44313. }
  44314. declare module BABYLON {
  44315. /**
  44316. * Raw texture data and descriptor sufficient for WebGL texture upload
  44317. */
  44318. export interface EnvironmentTextureInfo {
  44319. /**
  44320. * Version of the environment map
  44321. */
  44322. version: number;
  44323. /**
  44324. * Width of image
  44325. */
  44326. width: number;
  44327. /**
  44328. * Irradiance information stored in the file.
  44329. */
  44330. irradiance: any;
  44331. /**
  44332. * Specular information stored in the file.
  44333. */
  44334. specular: any;
  44335. }
  44336. /**
  44337. * Defines One Image in the file. It requires only the position in the file
  44338. * as well as the length.
  44339. */
  44340. interface BufferImageData {
  44341. /**
  44342. * Length of the image data.
  44343. */
  44344. length: number;
  44345. /**
  44346. * Position of the data from the null terminator delimiting the end of the JSON.
  44347. */
  44348. position: number;
  44349. }
  44350. /**
  44351. * Defines the specular data enclosed in the file.
  44352. * This corresponds to the version 1 of the data.
  44353. */
  44354. export interface EnvironmentTextureSpecularInfoV1 {
  44355. /**
  44356. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44357. */
  44358. specularDataPosition?: number;
  44359. /**
  44360. * This contains all the images data needed to reconstruct the cubemap.
  44361. */
  44362. mipmaps: Array<BufferImageData>;
  44363. /**
  44364. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44365. */
  44366. lodGenerationScale: number;
  44367. }
  44368. /**
  44369. * Sets of helpers addressing the serialization and deserialization of environment texture
  44370. * stored in a BabylonJS env file.
  44371. * Those files are usually stored as .env files.
  44372. */
  44373. export class EnvironmentTextureTools {
  44374. /**
  44375. * Magic number identifying the env file.
  44376. */
  44377. private static _MagicBytes;
  44378. /**
  44379. * Gets the environment info from an env file.
  44380. * @param data The array buffer containing the .env bytes.
  44381. * @returns the environment file info (the json header) if successfully parsed.
  44382. */
  44383. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44384. /**
  44385. * Creates an environment texture from a loaded cube texture.
  44386. * @param texture defines the cube texture to convert in env file
  44387. * @return a promise containing the environment data if succesfull.
  44388. */
  44389. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44390. /**
  44391. * Creates a JSON representation of the spherical data.
  44392. * @param texture defines the texture containing the polynomials
  44393. * @return the JSON representation of the spherical info
  44394. */
  44395. private static _CreateEnvTextureIrradiance;
  44396. /**
  44397. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44398. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44399. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44400. * @return the views described by info providing access to the underlying buffer
  44401. */
  44402. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44403. /**
  44404. * Uploads the texture info contained in the env file to the GPU.
  44405. * @param texture defines the internal texture to upload to
  44406. * @param arrayBuffer defines the buffer cotaining the data to load
  44407. * @param info defines the texture info retrieved through the GetEnvInfo method
  44408. * @returns a promise
  44409. */
  44410. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44411. /**
  44412. * Uploads the levels of image data to the GPU.
  44413. * @param texture defines the internal texture to upload to
  44414. * @param imageData defines the array buffer views of image data [mipmap][face]
  44415. * @returns a promise
  44416. */
  44417. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44418. /**
  44419. * Uploads spherical polynomials information to the texture.
  44420. * @param texture defines the texture we are trying to upload the information to
  44421. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44422. */
  44423. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44424. /** @hidden */
  44425. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44426. }
  44427. }
  44428. declare module BABYLON {
  44429. /**
  44430. * Contains position and normal vectors for a vertex
  44431. */
  44432. export class PositionNormalVertex {
  44433. /** the position of the vertex (defaut: 0,0,0) */
  44434. position: Vector3;
  44435. /** the normal of the vertex (defaut: 0,1,0) */
  44436. normal: Vector3;
  44437. /**
  44438. * Creates a PositionNormalVertex
  44439. * @param position the position of the vertex (defaut: 0,0,0)
  44440. * @param normal the normal of the vertex (defaut: 0,1,0)
  44441. */
  44442. constructor(
  44443. /** the position of the vertex (defaut: 0,0,0) */
  44444. position?: Vector3,
  44445. /** the normal of the vertex (defaut: 0,1,0) */
  44446. normal?: Vector3);
  44447. /**
  44448. * Clones the PositionNormalVertex
  44449. * @returns the cloned PositionNormalVertex
  44450. */
  44451. clone(): PositionNormalVertex;
  44452. }
  44453. /**
  44454. * Contains position, normal and uv vectors for a vertex
  44455. */
  44456. export class PositionNormalTextureVertex {
  44457. /** the position of the vertex (defaut: 0,0,0) */
  44458. position: Vector3;
  44459. /** the normal of the vertex (defaut: 0,1,0) */
  44460. normal: Vector3;
  44461. /** the uv of the vertex (default: 0,0) */
  44462. uv: Vector2;
  44463. /**
  44464. * Creates a PositionNormalTextureVertex
  44465. * @param position the position of the vertex (defaut: 0,0,0)
  44466. * @param normal the normal of the vertex (defaut: 0,1,0)
  44467. * @param uv the uv of the vertex (default: 0,0)
  44468. */
  44469. constructor(
  44470. /** the position of the vertex (defaut: 0,0,0) */
  44471. position?: Vector3,
  44472. /** the normal of the vertex (defaut: 0,1,0) */
  44473. normal?: Vector3,
  44474. /** the uv of the vertex (default: 0,0) */
  44475. uv?: Vector2);
  44476. /**
  44477. * Clones the PositionNormalTextureVertex
  44478. * @returns the cloned PositionNormalTextureVertex
  44479. */
  44480. clone(): PositionNormalTextureVertex;
  44481. }
  44482. }
  44483. declare module BABYLON {
  44484. /** @hidden */
  44485. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44486. private _genericAttributeLocation;
  44487. private _varyingLocationCount;
  44488. private _varyingLocationMap;
  44489. private _replacements;
  44490. private _textureCount;
  44491. private _uniforms;
  44492. lineProcessor(line: string): string;
  44493. attributeProcessor(attribute: string): string;
  44494. varyingProcessor(varying: string, isFragment: boolean): string;
  44495. uniformProcessor(uniform: string): string;
  44496. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44497. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44498. }
  44499. }
  44500. declare module BABYLON {
  44501. /**
  44502. * Container for accessors for natively-stored mesh data buffers.
  44503. */
  44504. class NativeDataBuffer extends DataBuffer {
  44505. /**
  44506. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44507. */
  44508. nativeIndexBuffer?: any;
  44509. /**
  44510. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44511. */
  44512. nativeVertexBuffer?: any;
  44513. }
  44514. /** @hidden */
  44515. export class NativeEngine extends Engine {
  44516. private readonly _native;
  44517. getHardwareScalingLevel(): number;
  44518. constructor();
  44519. /**
  44520. * Can be used to override the current requestAnimationFrame requester.
  44521. * @hidden
  44522. */
  44523. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44524. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44525. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44526. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44527. recordVertexArrayObject(vertexBuffers: {
  44528. [key: string]: VertexBuffer;
  44529. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44530. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44531. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44532. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44533. /**
  44534. * Draw a list of indexed primitives
  44535. * @param fillMode defines the primitive to use
  44536. * @param indexStart defines the starting index
  44537. * @param indexCount defines the number of index to draw
  44538. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44539. */
  44540. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44541. /**
  44542. * Draw a list of unindexed primitives
  44543. * @param fillMode defines the primitive to use
  44544. * @param verticesStart defines the index of first vertex to draw
  44545. * @param verticesCount defines the count of vertices to draw
  44546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44547. */
  44548. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44549. createPipelineContext(): IPipelineContext;
  44550. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44551. /** @hidden */
  44552. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44553. /** @hidden */
  44554. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44555. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44556. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44557. protected _setProgram(program: WebGLProgram): void;
  44558. _releaseEffect(effect: Effect): void;
  44559. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44560. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44561. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44562. bindSamplers(effect: Effect): void;
  44563. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44564. getRenderWidth(useScreen?: boolean): number;
  44565. getRenderHeight(useScreen?: boolean): number;
  44566. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44567. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44568. /**
  44569. * Set the z offset to apply to current rendering
  44570. * @param value defines the offset to apply
  44571. */
  44572. setZOffset(value: number): void;
  44573. /**
  44574. * Gets the current value of the zOffset
  44575. * @returns the current zOffset state
  44576. */
  44577. getZOffset(): number;
  44578. /**
  44579. * Enable or disable depth buffering
  44580. * @param enable defines the state to set
  44581. */
  44582. setDepthBuffer(enable: boolean): void;
  44583. /**
  44584. * Gets a boolean indicating if depth writing is enabled
  44585. * @returns the current depth writing state
  44586. */
  44587. getDepthWrite(): boolean;
  44588. /**
  44589. * Enable or disable depth writing
  44590. * @param enable defines the state to set
  44591. */
  44592. setDepthWrite(enable: boolean): void;
  44593. /**
  44594. * Enable or disable color writing
  44595. * @param enable defines the state to set
  44596. */
  44597. setColorWrite(enable: boolean): void;
  44598. /**
  44599. * Gets a boolean indicating if color writing is enabled
  44600. * @returns the current color writing state
  44601. */
  44602. getColorWrite(): boolean;
  44603. /**
  44604. * Sets alpha constants used by some alpha blending modes
  44605. * @param r defines the red component
  44606. * @param g defines the green component
  44607. * @param b defines the blue component
  44608. * @param a defines the alpha component
  44609. */
  44610. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44611. /**
  44612. * Sets the current alpha mode
  44613. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44614. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44615. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44616. */
  44617. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44618. /**
  44619. * Gets the current alpha mode
  44620. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44621. * @returns the current alpha mode
  44622. */
  44623. getAlphaMode(): number;
  44624. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44625. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44626. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44627. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44628. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44629. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44630. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44631. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44632. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44633. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44634. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44635. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44636. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44637. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44638. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44639. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44640. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44641. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44642. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44643. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44644. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44645. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44646. wipeCaches(bruteForce?: boolean): void;
  44647. _createTexture(): WebGLTexture;
  44648. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44649. /**
  44650. * Usually called from BABYLON.Texture.ts.
  44651. * Passed information to create a WebGLTexture
  44652. * @param urlArg defines a value which contains one of the following:
  44653. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44654. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44655. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44657. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44658. * @param scene needed for loading to the correct scene
  44659. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44660. * @param onLoad optional callback to be called upon successful completion
  44661. * @param onError optional callback to be called upon failure
  44662. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44663. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44664. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44665. * @param forcedExtension defines the extension to use to pick the right loader
  44666. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44667. */
  44668. 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;
  44669. /**
  44670. * Creates a cube texture
  44671. * @param rootUrl defines the url where the files to load is located
  44672. * @param scene defines the current scene
  44673. * @param files defines the list of files to load (1 per face)
  44674. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44675. * @param onLoad defines an optional callback raised when the texture is loaded
  44676. * @param onError defines an optional callback raised if there is an issue to load the texture
  44677. * @param format defines the format of the data
  44678. * @param forcedExtension defines the extension to use to pick the right loader
  44679. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44680. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44681. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44682. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44683. * @returns the cube texture as an InternalTexture
  44684. */
  44685. 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;
  44686. private _getSamplingFilter;
  44687. private static _GetNativeTextureFormat;
  44688. createRenderTargetTexture(size: number | {
  44689. width: number;
  44690. height: number;
  44691. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44692. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44693. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44694. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44695. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44696. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44697. /**
  44698. * Updates a dynamic vertex buffer.
  44699. * @param vertexBuffer the vertex buffer to update
  44700. * @param data the data used to update the vertex buffer
  44701. * @param byteOffset the byte offset of the data (optional)
  44702. * @param byteLength the byte length of the data (optional)
  44703. */
  44704. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44705. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44706. private _updateAnisotropicLevel;
  44707. private _getAddressMode;
  44708. /** @hidden */
  44709. _bindTexture(channel: number, texture: InternalTexture): void;
  44710. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44711. releaseEffects(): void;
  44712. /** @hidden */
  44713. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44714. /** @hidden */
  44715. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44716. /** @hidden */
  44717. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44718. /** @hidden */
  44719. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44720. }
  44721. }
  44722. declare module BABYLON {
  44723. /**
  44724. * Gather the list of clipboard event types as constants.
  44725. */
  44726. export class ClipboardEventTypes {
  44727. /**
  44728. * The clipboard event is fired when a copy command is active (pressed).
  44729. */
  44730. static readonly COPY: number;
  44731. /**
  44732. * The clipboard event is fired when a cut command is active (pressed).
  44733. */
  44734. static readonly CUT: number;
  44735. /**
  44736. * The clipboard event is fired when a paste command is active (pressed).
  44737. */
  44738. static readonly PASTE: number;
  44739. }
  44740. /**
  44741. * This class is used to store clipboard related info for the onClipboardObservable event.
  44742. */
  44743. export class ClipboardInfo {
  44744. /**
  44745. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44746. */
  44747. type: number;
  44748. /**
  44749. * Defines the related dom event
  44750. */
  44751. event: ClipboardEvent;
  44752. /**
  44753. *Creates an instance of ClipboardInfo.
  44754. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44755. * @param event Defines the related dom event
  44756. */
  44757. constructor(
  44758. /**
  44759. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44760. */
  44761. type: number,
  44762. /**
  44763. * Defines the related dom event
  44764. */
  44765. event: ClipboardEvent);
  44766. /**
  44767. * Get the clipboard event's type from the keycode.
  44768. * @param keyCode Defines the keyCode for the current keyboard event.
  44769. * @return {number}
  44770. */
  44771. static GetTypeFromCharacter(keyCode: number): number;
  44772. }
  44773. }
  44774. declare module BABYLON {
  44775. /**
  44776. * Google Daydream controller
  44777. */
  44778. export class DaydreamController extends WebVRController {
  44779. /**
  44780. * Base Url for the controller model.
  44781. */
  44782. static MODEL_BASE_URL: string;
  44783. /**
  44784. * File name for the controller model.
  44785. */
  44786. static MODEL_FILENAME: string;
  44787. /**
  44788. * Gamepad Id prefix used to identify Daydream Controller.
  44789. */
  44790. static readonly GAMEPAD_ID_PREFIX: string;
  44791. /**
  44792. * Creates a new DaydreamController from a gamepad
  44793. * @param vrGamepad the gamepad that the controller should be created from
  44794. */
  44795. constructor(vrGamepad: any);
  44796. /**
  44797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44798. * @param scene scene in which to add meshes
  44799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44800. */
  44801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44802. /**
  44803. * Called once for each button that changed state since the last frame
  44804. * @param buttonIdx Which button index changed
  44805. * @param state New state of the button
  44806. * @param changes Which properties on the state changed since last frame
  44807. */
  44808. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44809. }
  44810. }
  44811. declare module BABYLON {
  44812. /**
  44813. * Gear VR Controller
  44814. */
  44815. export class GearVRController extends WebVRController {
  44816. /**
  44817. * Base Url for the controller model.
  44818. */
  44819. static MODEL_BASE_URL: string;
  44820. /**
  44821. * File name for the controller model.
  44822. */
  44823. static MODEL_FILENAME: string;
  44824. /**
  44825. * Gamepad Id prefix used to identify this controller.
  44826. */
  44827. static readonly GAMEPAD_ID_PREFIX: string;
  44828. private readonly _buttonIndexToObservableNameMap;
  44829. /**
  44830. * Creates a new GearVRController from a gamepad
  44831. * @param vrGamepad the gamepad that the controller should be created from
  44832. */
  44833. constructor(vrGamepad: any);
  44834. /**
  44835. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44836. * @param scene scene in which to add meshes
  44837. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44838. */
  44839. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44840. /**
  44841. * Called once for each button that changed state since the last frame
  44842. * @param buttonIdx Which button index changed
  44843. * @param state New state of the button
  44844. * @param changes Which properties on the state changed since last frame
  44845. */
  44846. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44847. }
  44848. }
  44849. declare module BABYLON {
  44850. /**
  44851. * Class containing static functions to help procedurally build meshes
  44852. */
  44853. export class PolyhedronBuilder {
  44854. /**
  44855. * Creates a polyhedron mesh
  44856. * * 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
  44857. * * The parameter `size` (positive float, default 1) sets the polygon size
  44858. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44859. * * 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`
  44860. * * 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
  44861. * * 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)`)
  44862. * * 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
  44863. * * 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
  44864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44865. * * 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
  44866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44867. * @param name defines the name of the mesh
  44868. * @param options defines the options used to create the mesh
  44869. * @param scene defines the hosting scene
  44870. * @returns the polyhedron mesh
  44871. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44872. */
  44873. static CreatePolyhedron(name: string, options: {
  44874. type?: number;
  44875. size?: number;
  44876. sizeX?: number;
  44877. sizeY?: number;
  44878. sizeZ?: number;
  44879. custom?: any;
  44880. faceUV?: Vector4[];
  44881. faceColors?: Color4[];
  44882. flat?: boolean;
  44883. updatable?: boolean;
  44884. sideOrientation?: number;
  44885. frontUVs?: Vector4;
  44886. backUVs?: Vector4;
  44887. }, scene?: Nullable<Scene>): Mesh;
  44888. }
  44889. }
  44890. declare module BABYLON {
  44891. /**
  44892. * Gizmo that enables scaling a mesh along 3 axis
  44893. */
  44894. export class ScaleGizmo extends Gizmo {
  44895. /**
  44896. * Internal gizmo used for interactions on the x axis
  44897. */
  44898. xGizmo: AxisScaleGizmo;
  44899. /**
  44900. * Internal gizmo used for interactions on the y axis
  44901. */
  44902. yGizmo: AxisScaleGizmo;
  44903. /**
  44904. * Internal gizmo used for interactions on the z axis
  44905. */
  44906. zGizmo: AxisScaleGizmo;
  44907. /**
  44908. * Internal gizmo used to scale all axis equally
  44909. */
  44910. uniformScaleGizmo: AxisScaleGizmo;
  44911. private _meshAttached;
  44912. private _updateGizmoRotationToMatchAttachedMesh;
  44913. private _snapDistance;
  44914. private _scaleRatio;
  44915. private _uniformScalingMesh;
  44916. private _octahedron;
  44917. /** Fires an event when any of it's sub gizmos are dragged */
  44918. onDragStartObservable: Observable<unknown>;
  44919. /** Fires an event when any of it's sub gizmos are released from dragging */
  44920. onDragEndObservable: Observable<unknown>;
  44921. attachedMesh: Nullable<AbstractMesh>;
  44922. /**
  44923. * Creates a ScaleGizmo
  44924. * @param gizmoLayer The utility layer the gizmo will be added to
  44925. */
  44926. constructor(gizmoLayer?: UtilityLayerRenderer);
  44927. updateGizmoRotationToMatchAttachedMesh: boolean;
  44928. /**
  44929. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44930. */
  44931. snapDistance: number;
  44932. /**
  44933. * Ratio for the scale of the gizmo (Default: 1)
  44934. */
  44935. scaleRatio: number;
  44936. /**
  44937. * Disposes of the gizmo
  44938. */
  44939. dispose(): void;
  44940. }
  44941. }
  44942. declare module BABYLON {
  44943. /**
  44944. * Single axis scale gizmo
  44945. */
  44946. export class AxisScaleGizmo extends Gizmo {
  44947. /**
  44948. * Drag behavior responsible for the gizmos dragging interactions
  44949. */
  44950. dragBehavior: PointerDragBehavior;
  44951. private _pointerObserver;
  44952. /**
  44953. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44954. */
  44955. snapDistance: number;
  44956. /**
  44957. * Event that fires each time the gizmo snaps to a new location.
  44958. * * snapDistance is the the change in distance
  44959. */
  44960. onSnapObservable: Observable<{
  44961. snapDistance: number;
  44962. }>;
  44963. /**
  44964. * If the scaling operation should be done on all axis (default: false)
  44965. */
  44966. uniformScaling: boolean;
  44967. private _isEnabled;
  44968. private _parent;
  44969. private _arrow;
  44970. private _coloredMaterial;
  44971. private _hoverMaterial;
  44972. /**
  44973. * Creates an AxisScaleGizmo
  44974. * @param gizmoLayer The utility layer the gizmo will be added to
  44975. * @param dragAxis The axis which the gizmo will be able to scale on
  44976. * @param color The color of the gizmo
  44977. */
  44978. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44979. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44980. /**
  44981. * If the gizmo is enabled
  44982. */
  44983. isEnabled: boolean;
  44984. /**
  44985. * Disposes of the gizmo
  44986. */
  44987. dispose(): void;
  44988. /**
  44989. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44990. * @param mesh The mesh to replace the default mesh of the gizmo
  44991. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44992. */
  44993. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44994. }
  44995. }
  44996. declare module BABYLON {
  44997. /**
  44998. * Bounding box gizmo
  44999. */
  45000. export class BoundingBoxGizmo extends Gizmo {
  45001. private _lineBoundingBox;
  45002. private _rotateSpheresParent;
  45003. private _scaleBoxesParent;
  45004. private _boundingDimensions;
  45005. private _renderObserver;
  45006. private _pointerObserver;
  45007. private _scaleDragSpeed;
  45008. private _tmpQuaternion;
  45009. private _tmpVector;
  45010. private _tmpRotationMatrix;
  45011. /**
  45012. * 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)
  45013. */
  45014. ignoreChildren: boolean;
  45015. /**
  45016. * 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)
  45017. */
  45018. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45019. /**
  45020. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45021. */
  45022. rotationSphereSize: number;
  45023. /**
  45024. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45025. */
  45026. scaleBoxSize: number;
  45027. /**
  45028. * 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)
  45029. */
  45030. fixedDragMeshScreenSize: boolean;
  45031. /**
  45032. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45033. */
  45034. fixedDragMeshScreenSizeDistanceFactor: number;
  45035. /**
  45036. * Fired when a rotation sphere or scale box is dragged
  45037. */
  45038. onDragStartObservable: Observable<{}>;
  45039. /**
  45040. * Fired when a scale box is dragged
  45041. */
  45042. onScaleBoxDragObservable: Observable<{}>;
  45043. /**
  45044. * Fired when a scale box drag is ended
  45045. */
  45046. onScaleBoxDragEndObservable: Observable<{}>;
  45047. /**
  45048. * Fired when a rotation sphere is dragged
  45049. */
  45050. onRotationSphereDragObservable: Observable<{}>;
  45051. /**
  45052. * Fired when a rotation sphere drag is ended
  45053. */
  45054. onRotationSphereDragEndObservable: Observable<{}>;
  45055. /**
  45056. * 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)
  45057. */
  45058. scalePivot: Nullable<Vector3>;
  45059. /**
  45060. * Mesh used as a pivot to rotate the attached mesh
  45061. */
  45062. private _anchorMesh;
  45063. private _existingMeshScale;
  45064. private _dragMesh;
  45065. private pointerDragBehavior;
  45066. private coloredMaterial;
  45067. private hoverColoredMaterial;
  45068. /**
  45069. * Sets the color of the bounding box gizmo
  45070. * @param color the color to set
  45071. */
  45072. setColor(color: Color3): void;
  45073. /**
  45074. * Creates an BoundingBoxGizmo
  45075. * @param gizmoLayer The utility layer the gizmo will be added to
  45076. * @param color The color of the gizmo
  45077. */
  45078. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45079. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45080. private _selectNode;
  45081. /**
  45082. * Updates the bounding box information for the Gizmo
  45083. */
  45084. updateBoundingBox(): void;
  45085. private _updateRotationSpheres;
  45086. private _updateScaleBoxes;
  45087. /**
  45088. * Enables rotation on the specified axis and disables rotation on the others
  45089. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45090. */
  45091. setEnabledRotationAxis(axis: string): void;
  45092. /**
  45093. * Enables/disables scaling
  45094. * @param enable if scaling should be enabled
  45095. */
  45096. setEnabledScaling(enable: boolean): void;
  45097. private _updateDummy;
  45098. /**
  45099. * Enables a pointer drag behavior on the bounding box of the gizmo
  45100. */
  45101. enableDragBehavior(): void;
  45102. /**
  45103. * Disposes of the gizmo
  45104. */
  45105. dispose(): void;
  45106. /**
  45107. * 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)
  45108. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45109. * @returns the bounding box mesh with the passed in mesh as a child
  45110. */
  45111. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45112. /**
  45113. * CustomMeshes are not supported by this gizmo
  45114. * @param mesh The mesh to replace the default mesh of the gizmo
  45115. */
  45116. setCustomMesh(mesh: Mesh): void;
  45117. }
  45118. }
  45119. declare module BABYLON {
  45120. /**
  45121. * Single plane rotation gizmo
  45122. */
  45123. export class PlaneRotationGizmo extends Gizmo {
  45124. /**
  45125. * Drag behavior responsible for the gizmos dragging interactions
  45126. */
  45127. dragBehavior: PointerDragBehavior;
  45128. private _pointerObserver;
  45129. /**
  45130. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45131. */
  45132. snapDistance: number;
  45133. /**
  45134. * Event that fires each time the gizmo snaps to a new location.
  45135. * * snapDistance is the the change in distance
  45136. */
  45137. onSnapObservable: Observable<{
  45138. snapDistance: number;
  45139. }>;
  45140. private _isEnabled;
  45141. private _parent;
  45142. /**
  45143. * Creates a PlaneRotationGizmo
  45144. * @param gizmoLayer The utility layer the gizmo will be added to
  45145. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45146. * @param color The color of the gizmo
  45147. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45148. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45149. */
  45150. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45151. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45152. /**
  45153. * If the gizmo is enabled
  45154. */
  45155. isEnabled: boolean;
  45156. /**
  45157. * Disposes of the gizmo
  45158. */
  45159. dispose(): void;
  45160. }
  45161. }
  45162. declare module BABYLON {
  45163. /**
  45164. * Gizmo that enables rotating a mesh along 3 axis
  45165. */
  45166. export class RotationGizmo extends Gizmo {
  45167. /**
  45168. * Internal gizmo used for interactions on the x axis
  45169. */
  45170. xGizmo: PlaneRotationGizmo;
  45171. /**
  45172. * Internal gizmo used for interactions on the y axis
  45173. */
  45174. yGizmo: PlaneRotationGizmo;
  45175. /**
  45176. * Internal gizmo used for interactions on the z axis
  45177. */
  45178. zGizmo: PlaneRotationGizmo;
  45179. /** Fires an event when any of it's sub gizmos are dragged */
  45180. onDragStartObservable: Observable<unknown>;
  45181. /** Fires an event when any of it's sub gizmos are released from dragging */
  45182. onDragEndObservable: Observable<unknown>;
  45183. private _meshAttached;
  45184. attachedMesh: Nullable<AbstractMesh>;
  45185. /**
  45186. * Creates a RotationGizmo
  45187. * @param gizmoLayer The utility layer the gizmo will be added to
  45188. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45189. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45190. */
  45191. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45192. updateGizmoRotationToMatchAttachedMesh: boolean;
  45193. /**
  45194. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45195. */
  45196. snapDistance: number;
  45197. /**
  45198. * Ratio for the scale of the gizmo (Default: 1)
  45199. */
  45200. scaleRatio: number;
  45201. /**
  45202. * Disposes of the gizmo
  45203. */
  45204. dispose(): void;
  45205. /**
  45206. * CustomMeshes are not supported by this gizmo
  45207. * @param mesh The mesh to replace the default mesh of the gizmo
  45208. */
  45209. setCustomMesh(mesh: Mesh): void;
  45210. }
  45211. }
  45212. declare module BABYLON {
  45213. /**
  45214. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45215. */
  45216. export class GizmoManager implements IDisposable {
  45217. private scene;
  45218. /**
  45219. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45220. */
  45221. gizmos: {
  45222. positionGizmo: Nullable<PositionGizmo>;
  45223. rotationGizmo: Nullable<RotationGizmo>;
  45224. scaleGizmo: Nullable<ScaleGizmo>;
  45225. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45226. };
  45227. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45228. clearGizmoOnEmptyPointerEvent: boolean;
  45229. /** Fires an event when the manager is attached to a mesh */
  45230. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45231. private _gizmosEnabled;
  45232. private _pointerObserver;
  45233. private _attachedMesh;
  45234. private _boundingBoxColor;
  45235. private _defaultUtilityLayer;
  45236. private _defaultKeepDepthUtilityLayer;
  45237. /**
  45238. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45239. */
  45240. boundingBoxDragBehavior: SixDofDragBehavior;
  45241. /**
  45242. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45243. */
  45244. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45245. /**
  45246. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45247. */
  45248. usePointerToAttachGizmos: boolean;
  45249. /**
  45250. * Utility layer that the bounding box gizmo belongs to
  45251. */
  45252. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45253. /**
  45254. * Utility layer that all gizmos besides bounding box belong to
  45255. */
  45256. readonly utilityLayer: UtilityLayerRenderer;
  45257. /**
  45258. * Instatiates a gizmo manager
  45259. * @param scene the scene to overlay the gizmos on top of
  45260. */
  45261. constructor(scene: Scene);
  45262. /**
  45263. * Attaches a set of gizmos to the specified mesh
  45264. * @param mesh The mesh the gizmo's should be attached to
  45265. */
  45266. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45267. /**
  45268. * If the position gizmo is enabled
  45269. */
  45270. positionGizmoEnabled: boolean;
  45271. /**
  45272. * If the rotation gizmo is enabled
  45273. */
  45274. rotationGizmoEnabled: boolean;
  45275. /**
  45276. * If the scale gizmo is enabled
  45277. */
  45278. scaleGizmoEnabled: boolean;
  45279. /**
  45280. * If the boundingBox gizmo is enabled
  45281. */
  45282. boundingBoxGizmoEnabled: boolean;
  45283. /**
  45284. * Disposes of the gizmo manager
  45285. */
  45286. dispose(): void;
  45287. }
  45288. }
  45289. declare module BABYLON {
  45290. /**
  45291. * A directional light is defined by a direction (what a surprise!).
  45292. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45293. * 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.
  45294. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45295. */
  45296. export class DirectionalLight extends ShadowLight {
  45297. private _shadowFrustumSize;
  45298. /**
  45299. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45300. */
  45301. /**
  45302. * Specifies a fix frustum size for the shadow generation.
  45303. */
  45304. shadowFrustumSize: number;
  45305. private _shadowOrthoScale;
  45306. /**
  45307. * Gets the shadow projection scale against the optimal computed one.
  45308. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45309. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45310. */
  45311. /**
  45312. * Sets the shadow projection scale against the optimal computed one.
  45313. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45314. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45315. */
  45316. shadowOrthoScale: number;
  45317. /**
  45318. * Automatically compute the projection matrix to best fit (including all the casters)
  45319. * on each frame.
  45320. */
  45321. autoUpdateExtends: boolean;
  45322. private _orthoLeft;
  45323. private _orthoRight;
  45324. private _orthoTop;
  45325. private _orthoBottom;
  45326. /**
  45327. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45328. * The directional light is emitted from everywhere in the given direction.
  45329. * It can cast shadows.
  45330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45331. * @param name The friendly name of the light
  45332. * @param direction The direction of the light
  45333. * @param scene The scene the light belongs to
  45334. */
  45335. constructor(name: string, direction: Vector3, scene: Scene);
  45336. /**
  45337. * Returns the string "DirectionalLight".
  45338. * @return The class name
  45339. */
  45340. getClassName(): string;
  45341. /**
  45342. * Returns the integer 1.
  45343. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45344. */
  45345. getTypeID(): number;
  45346. /**
  45347. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45348. * Returns the DirectionalLight Shadow projection matrix.
  45349. */
  45350. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45351. /**
  45352. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45353. * Returns the DirectionalLight Shadow projection matrix.
  45354. */
  45355. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45356. /**
  45357. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45358. * Returns the DirectionalLight Shadow projection matrix.
  45359. */
  45360. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45361. protected _buildUniformLayout(): void;
  45362. /**
  45363. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45364. * @param effect The effect to update
  45365. * @param lightIndex The index of the light in the effect to update
  45366. * @returns The directional light
  45367. */
  45368. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45369. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45370. /**
  45371. * Gets the minZ used for shadow according to both the scene and the light.
  45372. *
  45373. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45374. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45375. * @param activeCamera The camera we are returning the min for
  45376. * @returns the depth min z
  45377. */
  45378. getDepthMinZ(activeCamera: Camera): number;
  45379. /**
  45380. * Gets the maxZ used for shadow according to both the scene and the light.
  45381. *
  45382. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45383. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45384. * @param activeCamera The camera we are returning the max for
  45385. * @returns the depth max z
  45386. */
  45387. getDepthMaxZ(activeCamera: Camera): number;
  45388. /**
  45389. * Prepares the list of defines specific to the light type.
  45390. * @param defines the list of defines
  45391. * @param lightIndex defines the index of the light for the effect
  45392. */
  45393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45394. }
  45395. }
  45396. declare module BABYLON {
  45397. /**
  45398. * Class containing static functions to help procedurally build meshes
  45399. */
  45400. export class HemisphereBuilder {
  45401. /**
  45402. * Creates a hemisphere mesh
  45403. * @param name defines the name of the mesh
  45404. * @param options defines the options used to create the mesh
  45405. * @param scene defines the hosting scene
  45406. * @returns the hemisphere mesh
  45407. */
  45408. static CreateHemisphere(name: string, options: {
  45409. segments?: number;
  45410. diameter?: number;
  45411. sideOrientation?: number;
  45412. }, scene: any): Mesh;
  45413. }
  45414. }
  45415. declare module BABYLON {
  45416. /**
  45417. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45418. * These values define a cone of light starting from the position, emitting toward the direction.
  45419. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45420. * and the exponent defines the speed of the decay of the light with distance (reach).
  45421. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45422. */
  45423. export class SpotLight extends ShadowLight {
  45424. private _angle;
  45425. private _innerAngle;
  45426. private _cosHalfAngle;
  45427. private _lightAngleScale;
  45428. private _lightAngleOffset;
  45429. /**
  45430. * Gets the cone angle of the spot light in Radians.
  45431. */
  45432. /**
  45433. * Sets the cone angle of the spot light in Radians.
  45434. */
  45435. angle: number;
  45436. /**
  45437. * Only used in gltf falloff mode, this defines the angle where
  45438. * the directional falloff will start before cutting at angle which could be seen
  45439. * as outer angle.
  45440. */
  45441. /**
  45442. * Only used in gltf falloff mode, this defines the angle where
  45443. * the directional falloff will start before cutting at angle which could be seen
  45444. * as outer angle.
  45445. */
  45446. innerAngle: number;
  45447. private _shadowAngleScale;
  45448. /**
  45449. * Allows scaling the angle of the light for shadow generation only.
  45450. */
  45451. /**
  45452. * Allows scaling the angle of the light for shadow generation only.
  45453. */
  45454. shadowAngleScale: number;
  45455. /**
  45456. * The light decay speed with the distance from the emission spot.
  45457. */
  45458. exponent: number;
  45459. private _projectionTextureMatrix;
  45460. /**
  45461. * Allows reading the projecton texture
  45462. */
  45463. readonly projectionTextureMatrix: Matrix;
  45464. protected _projectionTextureLightNear: number;
  45465. /**
  45466. * Gets the near clip of the Spotlight for texture projection.
  45467. */
  45468. /**
  45469. * Sets the near clip of the Spotlight for texture projection.
  45470. */
  45471. projectionTextureLightNear: number;
  45472. protected _projectionTextureLightFar: number;
  45473. /**
  45474. * Gets the far clip of the Spotlight for texture projection.
  45475. */
  45476. /**
  45477. * Sets the far clip of the Spotlight for texture projection.
  45478. */
  45479. projectionTextureLightFar: number;
  45480. protected _projectionTextureUpDirection: Vector3;
  45481. /**
  45482. * Gets the Up vector of the Spotlight for texture projection.
  45483. */
  45484. /**
  45485. * Sets the Up vector of the Spotlight for texture projection.
  45486. */
  45487. projectionTextureUpDirection: Vector3;
  45488. private _projectionTexture;
  45489. /**
  45490. * Gets the projection texture of the light.
  45491. */
  45492. /**
  45493. * Sets the projection texture of the light.
  45494. */
  45495. projectionTexture: Nullable<BaseTexture>;
  45496. private _projectionTextureViewLightDirty;
  45497. private _projectionTextureProjectionLightDirty;
  45498. private _projectionTextureDirty;
  45499. private _projectionTextureViewTargetVector;
  45500. private _projectionTextureViewLightMatrix;
  45501. private _projectionTextureProjectionLightMatrix;
  45502. private _projectionTextureScalingMatrix;
  45503. /**
  45504. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45505. * It can cast shadows.
  45506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45507. * @param name The light friendly name
  45508. * @param position The position of the spot light in the scene
  45509. * @param direction The direction of the light in the scene
  45510. * @param angle The cone angle of the light in Radians
  45511. * @param exponent The light decay speed with the distance from the emission spot
  45512. * @param scene The scene the lights belongs to
  45513. */
  45514. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45515. /**
  45516. * Returns the string "SpotLight".
  45517. * @returns the class name
  45518. */
  45519. getClassName(): string;
  45520. /**
  45521. * Returns the integer 2.
  45522. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45523. */
  45524. getTypeID(): number;
  45525. /**
  45526. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45527. */
  45528. protected _setDirection(value: Vector3): void;
  45529. /**
  45530. * Overrides the position setter to recompute the projection texture view light Matrix.
  45531. */
  45532. protected _setPosition(value: Vector3): void;
  45533. /**
  45534. * 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.
  45535. * Returns the SpotLight.
  45536. */
  45537. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45538. protected _computeProjectionTextureViewLightMatrix(): void;
  45539. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45540. /**
  45541. * Main function for light texture projection matrix computing.
  45542. */
  45543. protected _computeProjectionTextureMatrix(): void;
  45544. protected _buildUniformLayout(): void;
  45545. private _computeAngleValues;
  45546. /**
  45547. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45548. * @param effect The effect to update
  45549. * @param lightIndex The index of the light in the effect to update
  45550. * @returns The spot light
  45551. */
  45552. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45553. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45554. /**
  45555. * Disposes the light and the associated resources.
  45556. */
  45557. dispose(): void;
  45558. /**
  45559. * Prepares the list of defines specific to the light type.
  45560. * @param defines the list of defines
  45561. * @param lightIndex defines the index of the light for the effect
  45562. */
  45563. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45564. }
  45565. }
  45566. declare module BABYLON {
  45567. /**
  45568. * Gizmo that enables viewing a light
  45569. */
  45570. export class LightGizmo extends Gizmo {
  45571. private _lightMesh;
  45572. private _material;
  45573. private cachedPosition;
  45574. private cachedForward;
  45575. /**
  45576. * Creates a LightGizmo
  45577. * @param gizmoLayer The utility layer the gizmo will be added to
  45578. */
  45579. constructor(gizmoLayer?: UtilityLayerRenderer);
  45580. private _light;
  45581. /**
  45582. * The light that the gizmo is attached to
  45583. */
  45584. light: Nullable<Light>;
  45585. /**
  45586. * Gets the material used to render the light gizmo
  45587. */
  45588. readonly material: StandardMaterial;
  45589. /**
  45590. * @hidden
  45591. * Updates the gizmo to match the attached mesh's position/rotation
  45592. */
  45593. protected _update(): void;
  45594. private static _Scale;
  45595. /**
  45596. * Creates the lines for a light mesh
  45597. */
  45598. private static _createLightLines;
  45599. /**
  45600. * Disposes of the light gizmo
  45601. */
  45602. dispose(): void;
  45603. private static _CreateHemisphericLightMesh;
  45604. private static _CreatePointLightMesh;
  45605. private static _CreateSpotLightMesh;
  45606. private static _CreateDirectionalLightMesh;
  45607. }
  45608. }
  45609. declare module BABYLON {
  45610. /** @hidden */
  45611. export var backgroundFragmentDeclaration: {
  45612. name: string;
  45613. shader: string;
  45614. };
  45615. }
  45616. declare module BABYLON {
  45617. /** @hidden */
  45618. export var backgroundUboDeclaration: {
  45619. name: string;
  45620. shader: string;
  45621. };
  45622. }
  45623. declare module BABYLON {
  45624. /** @hidden */
  45625. export var backgroundPixelShader: {
  45626. name: string;
  45627. shader: string;
  45628. };
  45629. }
  45630. declare module BABYLON {
  45631. /** @hidden */
  45632. export var backgroundVertexDeclaration: {
  45633. name: string;
  45634. shader: string;
  45635. };
  45636. }
  45637. declare module BABYLON {
  45638. /** @hidden */
  45639. export var backgroundVertexShader: {
  45640. name: string;
  45641. shader: string;
  45642. };
  45643. }
  45644. declare module BABYLON {
  45645. /**
  45646. * Background material used to create an efficient environement around your scene.
  45647. */
  45648. export class BackgroundMaterial extends PushMaterial {
  45649. /**
  45650. * Standard reflectance value at parallel view angle.
  45651. */
  45652. static StandardReflectance0: number;
  45653. /**
  45654. * Standard reflectance value at grazing angle.
  45655. */
  45656. static StandardReflectance90: number;
  45657. protected _primaryColor: Color3;
  45658. /**
  45659. * Key light Color (multiply against the environement texture)
  45660. */
  45661. primaryColor: Color3;
  45662. protected __perceptualColor: Nullable<Color3>;
  45663. /**
  45664. * Experimental Internal Use Only.
  45665. *
  45666. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45667. * This acts as a helper to set the primary color to a more "human friendly" value.
  45668. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45669. * output color as close as possible from the chosen value.
  45670. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45671. * part of lighting setup.)
  45672. */
  45673. _perceptualColor: Nullable<Color3>;
  45674. protected _primaryColorShadowLevel: float;
  45675. /**
  45676. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45677. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45678. */
  45679. primaryColorShadowLevel: float;
  45680. protected _primaryColorHighlightLevel: float;
  45681. /**
  45682. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45683. * The primary color is used at the level chosen to define what the white area would look.
  45684. */
  45685. primaryColorHighlightLevel: float;
  45686. protected _reflectionTexture: Nullable<BaseTexture>;
  45687. /**
  45688. * Reflection Texture used in the material.
  45689. * Should be author in a specific way for the best result (refer to the documentation).
  45690. */
  45691. reflectionTexture: Nullable<BaseTexture>;
  45692. protected _reflectionBlur: float;
  45693. /**
  45694. * Reflection Texture level of blur.
  45695. *
  45696. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45697. * texture twice.
  45698. */
  45699. reflectionBlur: float;
  45700. protected _diffuseTexture: Nullable<BaseTexture>;
  45701. /**
  45702. * Diffuse Texture used in the material.
  45703. * Should be author in a specific way for the best result (refer to the documentation).
  45704. */
  45705. diffuseTexture: Nullable<BaseTexture>;
  45706. protected _shadowLights: Nullable<IShadowLight[]>;
  45707. /**
  45708. * Specify the list of lights casting shadow on the material.
  45709. * All scene shadow lights will be included if null.
  45710. */
  45711. shadowLights: Nullable<IShadowLight[]>;
  45712. protected _shadowLevel: float;
  45713. /**
  45714. * Helps adjusting the shadow to a softer level if required.
  45715. * 0 means black shadows and 1 means no shadows.
  45716. */
  45717. shadowLevel: float;
  45718. protected _sceneCenter: Vector3;
  45719. /**
  45720. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45721. * It is usually zero but might be interesting to modify according to your setup.
  45722. */
  45723. sceneCenter: Vector3;
  45724. protected _opacityFresnel: boolean;
  45725. /**
  45726. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45727. * This helps ensuring a nice transition when the camera goes under the ground.
  45728. */
  45729. opacityFresnel: boolean;
  45730. protected _reflectionFresnel: boolean;
  45731. /**
  45732. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45733. * This helps adding a mirror texture on the ground.
  45734. */
  45735. reflectionFresnel: boolean;
  45736. protected _reflectionFalloffDistance: number;
  45737. /**
  45738. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45739. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45740. */
  45741. reflectionFalloffDistance: number;
  45742. protected _reflectionAmount: number;
  45743. /**
  45744. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45745. */
  45746. reflectionAmount: number;
  45747. protected _reflectionReflectance0: number;
  45748. /**
  45749. * This specifies the weight of the reflection at grazing angle.
  45750. */
  45751. reflectionReflectance0: number;
  45752. protected _reflectionReflectance90: number;
  45753. /**
  45754. * This specifies the weight of the reflection at a perpendicular point of view.
  45755. */
  45756. reflectionReflectance90: number;
  45757. /**
  45758. * Sets the reflection reflectance fresnel values according to the default standard
  45759. * empirically know to work well :-)
  45760. */
  45761. reflectionStandardFresnelWeight: number;
  45762. protected _useRGBColor: boolean;
  45763. /**
  45764. * Helps to directly use the maps channels instead of their level.
  45765. */
  45766. useRGBColor: boolean;
  45767. protected _enableNoise: boolean;
  45768. /**
  45769. * This helps reducing the banding effect that could occur on the background.
  45770. */
  45771. enableNoise: boolean;
  45772. /**
  45773. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45774. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45775. * Recommended to be keep at 1.0 except for special cases.
  45776. */
  45777. fovMultiplier: number;
  45778. private _fovMultiplier;
  45779. /**
  45780. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45781. */
  45782. useEquirectangularFOV: boolean;
  45783. private _maxSimultaneousLights;
  45784. /**
  45785. * Number of Simultaneous lights allowed on the material.
  45786. */
  45787. maxSimultaneousLights: int;
  45788. /**
  45789. * Default configuration related to image processing available in the Background Material.
  45790. */
  45791. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45792. /**
  45793. * Keep track of the image processing observer to allow dispose and replace.
  45794. */
  45795. private _imageProcessingObserver;
  45796. /**
  45797. * Attaches a new image processing configuration to the PBR Material.
  45798. * @param configuration (if null the scene configuration will be use)
  45799. */
  45800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45801. /**
  45802. * Gets the image processing configuration used either in this material.
  45803. */
  45804. /**
  45805. * Sets the Default image processing configuration used either in the this material.
  45806. *
  45807. * If sets to null, the scene one is in use.
  45808. */
  45809. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45810. /**
  45811. * Gets wether the color curves effect is enabled.
  45812. */
  45813. /**
  45814. * Sets wether the color curves effect is enabled.
  45815. */
  45816. cameraColorCurvesEnabled: boolean;
  45817. /**
  45818. * Gets wether the color grading effect is enabled.
  45819. */
  45820. /**
  45821. * Gets wether the color grading effect is enabled.
  45822. */
  45823. cameraColorGradingEnabled: boolean;
  45824. /**
  45825. * Gets wether tonemapping is enabled or not.
  45826. */
  45827. /**
  45828. * Sets wether tonemapping is enabled or not
  45829. */
  45830. cameraToneMappingEnabled: boolean;
  45831. /**
  45832. * The camera exposure used on this material.
  45833. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45834. * This corresponds to a photographic exposure.
  45835. */
  45836. /**
  45837. * The camera exposure used on this material.
  45838. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45839. * This corresponds to a photographic exposure.
  45840. */
  45841. cameraExposure: float;
  45842. /**
  45843. * Gets The camera contrast used on this material.
  45844. */
  45845. /**
  45846. * Sets The camera contrast used on this material.
  45847. */
  45848. cameraContrast: float;
  45849. /**
  45850. * Gets the Color Grading 2D Lookup Texture.
  45851. */
  45852. /**
  45853. * Sets the Color Grading 2D Lookup Texture.
  45854. */
  45855. cameraColorGradingTexture: Nullable<BaseTexture>;
  45856. /**
  45857. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45858. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45859. * 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;
  45860. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45861. */
  45862. /**
  45863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45865. * 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;
  45866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45867. */
  45868. cameraColorCurves: Nullable<ColorCurves>;
  45869. /**
  45870. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45871. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45872. */
  45873. switchToBGR: boolean;
  45874. private _renderTargets;
  45875. private _reflectionControls;
  45876. private _white;
  45877. private _primaryShadowColor;
  45878. private _primaryHighlightColor;
  45879. /**
  45880. * Instantiates a Background Material in the given scene
  45881. * @param name The friendly name of the material
  45882. * @param scene The scene to add the material to
  45883. */
  45884. constructor(name: string, scene: Scene);
  45885. /**
  45886. * Gets a boolean indicating that current material needs to register RTT
  45887. */
  45888. readonly hasRenderTargetTextures: boolean;
  45889. /**
  45890. * The entire material has been created in order to prevent overdraw.
  45891. * @returns false
  45892. */
  45893. needAlphaTesting(): boolean;
  45894. /**
  45895. * The entire material has been created in order to prevent overdraw.
  45896. * @returns true if blending is enable
  45897. */
  45898. needAlphaBlending(): boolean;
  45899. /**
  45900. * Checks wether the material is ready to be rendered for a given mesh.
  45901. * @param mesh The mesh to render
  45902. * @param subMesh The submesh to check against
  45903. * @param useInstances Specify wether or not the material is used with instances
  45904. * @returns true if all the dependencies are ready (Textures, Effects...)
  45905. */
  45906. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45907. /**
  45908. * Compute the primary color according to the chosen perceptual color.
  45909. */
  45910. private _computePrimaryColorFromPerceptualColor;
  45911. /**
  45912. * Compute the highlights and shadow colors according to their chosen levels.
  45913. */
  45914. private _computePrimaryColors;
  45915. /**
  45916. * Build the uniform buffer used in the material.
  45917. */
  45918. buildUniformLayout(): void;
  45919. /**
  45920. * Unbind the material.
  45921. */
  45922. unbind(): void;
  45923. /**
  45924. * Bind only the world matrix to the material.
  45925. * @param world The world matrix to bind.
  45926. */
  45927. bindOnlyWorldMatrix(world: Matrix): void;
  45928. /**
  45929. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45930. * @param world The world matrix to bind.
  45931. * @param subMesh The submesh to bind for.
  45932. */
  45933. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45934. /**
  45935. * Checks to see if a texture is used in the material.
  45936. * @param texture - Base texture to use.
  45937. * @returns - Boolean specifying if a texture is used in the material.
  45938. */
  45939. hasTexture(texture: BaseTexture): boolean;
  45940. /**
  45941. * Dispose the material.
  45942. * @param forceDisposeEffect Force disposal of the associated effect.
  45943. * @param forceDisposeTextures Force disposal of the associated textures.
  45944. */
  45945. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45946. /**
  45947. * Clones the material.
  45948. * @param name The cloned name.
  45949. * @returns The cloned material.
  45950. */
  45951. clone(name: string): BackgroundMaterial;
  45952. /**
  45953. * Serializes the current material to its JSON representation.
  45954. * @returns The JSON representation.
  45955. */
  45956. serialize(): any;
  45957. /**
  45958. * Gets the class name of the material
  45959. * @returns "BackgroundMaterial"
  45960. */
  45961. getClassName(): string;
  45962. /**
  45963. * Parse a JSON input to create back a background material.
  45964. * @param source The JSON data to parse
  45965. * @param scene The scene to create the parsed material in
  45966. * @param rootUrl The root url of the assets the material depends upon
  45967. * @returns the instantiated BackgroundMaterial.
  45968. */
  45969. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45970. }
  45971. }
  45972. declare module BABYLON {
  45973. /**
  45974. * Represents the different options available during the creation of
  45975. * a Environment helper.
  45976. *
  45977. * This can control the default ground, skybox and image processing setup of your scene.
  45978. */
  45979. export interface IEnvironmentHelperOptions {
  45980. /**
  45981. * Specifies wether or not to create a ground.
  45982. * True by default.
  45983. */
  45984. createGround: boolean;
  45985. /**
  45986. * Specifies the ground size.
  45987. * 15 by default.
  45988. */
  45989. groundSize: number;
  45990. /**
  45991. * The texture used on the ground for the main color.
  45992. * Comes from the BabylonJS CDN by default.
  45993. *
  45994. * Remarks: Can be either a texture or a url.
  45995. */
  45996. groundTexture: string | BaseTexture;
  45997. /**
  45998. * The color mixed in the ground texture by default.
  45999. * BabylonJS clearColor by default.
  46000. */
  46001. groundColor: Color3;
  46002. /**
  46003. * Specifies the ground opacity.
  46004. * 1 by default.
  46005. */
  46006. groundOpacity: number;
  46007. /**
  46008. * Enables the ground to receive shadows.
  46009. * True by default.
  46010. */
  46011. enableGroundShadow: boolean;
  46012. /**
  46013. * Helps preventing the shadow to be fully black on the ground.
  46014. * 0.5 by default.
  46015. */
  46016. groundShadowLevel: number;
  46017. /**
  46018. * Creates a mirror texture attach to the ground.
  46019. * false by default.
  46020. */
  46021. enableGroundMirror: boolean;
  46022. /**
  46023. * Specifies the ground mirror size ratio.
  46024. * 0.3 by default as the default kernel is 64.
  46025. */
  46026. groundMirrorSizeRatio: number;
  46027. /**
  46028. * Specifies the ground mirror blur kernel size.
  46029. * 64 by default.
  46030. */
  46031. groundMirrorBlurKernel: number;
  46032. /**
  46033. * Specifies the ground mirror visibility amount.
  46034. * 1 by default
  46035. */
  46036. groundMirrorAmount: number;
  46037. /**
  46038. * Specifies the ground mirror reflectance weight.
  46039. * This uses the standard weight of the background material to setup the fresnel effect
  46040. * of the mirror.
  46041. * 1 by default.
  46042. */
  46043. groundMirrorFresnelWeight: number;
  46044. /**
  46045. * Specifies the ground mirror Falloff distance.
  46046. * This can helps reducing the size of the reflection.
  46047. * 0 by Default.
  46048. */
  46049. groundMirrorFallOffDistance: number;
  46050. /**
  46051. * Specifies the ground mirror texture type.
  46052. * Unsigned Int by Default.
  46053. */
  46054. groundMirrorTextureType: number;
  46055. /**
  46056. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46057. * the shown objects.
  46058. */
  46059. groundYBias: number;
  46060. /**
  46061. * Specifies wether or not to create a skybox.
  46062. * True by default.
  46063. */
  46064. createSkybox: boolean;
  46065. /**
  46066. * Specifies the skybox size.
  46067. * 20 by default.
  46068. */
  46069. skyboxSize: number;
  46070. /**
  46071. * The texture used on the skybox for the main color.
  46072. * Comes from the BabylonJS CDN by default.
  46073. *
  46074. * Remarks: Can be either a texture or a url.
  46075. */
  46076. skyboxTexture: string | BaseTexture;
  46077. /**
  46078. * The color mixed in the skybox texture by default.
  46079. * BabylonJS clearColor by default.
  46080. */
  46081. skyboxColor: Color3;
  46082. /**
  46083. * The background rotation around the Y axis of the scene.
  46084. * This helps aligning the key lights of your scene with the background.
  46085. * 0 by default.
  46086. */
  46087. backgroundYRotation: number;
  46088. /**
  46089. * Compute automatically the size of the elements to best fit with the scene.
  46090. */
  46091. sizeAuto: boolean;
  46092. /**
  46093. * Default position of the rootMesh if autoSize is not true.
  46094. */
  46095. rootPosition: Vector3;
  46096. /**
  46097. * Sets up the image processing in the scene.
  46098. * true by default.
  46099. */
  46100. setupImageProcessing: boolean;
  46101. /**
  46102. * The texture used as your environment texture in the scene.
  46103. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46104. *
  46105. * Remarks: Can be either a texture or a url.
  46106. */
  46107. environmentTexture: string | BaseTexture;
  46108. /**
  46109. * The value of the exposure to apply to the scene.
  46110. * 0.6 by default if setupImageProcessing is true.
  46111. */
  46112. cameraExposure: number;
  46113. /**
  46114. * The value of the contrast to apply to the scene.
  46115. * 1.6 by default if setupImageProcessing is true.
  46116. */
  46117. cameraContrast: number;
  46118. /**
  46119. * Specifies wether or not tonemapping should be enabled in the scene.
  46120. * true by default if setupImageProcessing is true.
  46121. */
  46122. toneMappingEnabled: boolean;
  46123. }
  46124. /**
  46125. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46126. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46127. * It also helps with the default setup of your imageProcessing configuration.
  46128. */
  46129. export class EnvironmentHelper {
  46130. /**
  46131. * Default ground texture URL.
  46132. */
  46133. private static _groundTextureCDNUrl;
  46134. /**
  46135. * Default skybox texture URL.
  46136. */
  46137. private static _skyboxTextureCDNUrl;
  46138. /**
  46139. * Default environment texture URL.
  46140. */
  46141. private static _environmentTextureCDNUrl;
  46142. /**
  46143. * Creates the default options for the helper.
  46144. */
  46145. private static _getDefaultOptions;
  46146. private _rootMesh;
  46147. /**
  46148. * Gets the root mesh created by the helper.
  46149. */
  46150. readonly rootMesh: Mesh;
  46151. private _skybox;
  46152. /**
  46153. * Gets the skybox created by the helper.
  46154. */
  46155. readonly skybox: Nullable<Mesh>;
  46156. private _skyboxTexture;
  46157. /**
  46158. * Gets the skybox texture created by the helper.
  46159. */
  46160. readonly skyboxTexture: Nullable<BaseTexture>;
  46161. private _skyboxMaterial;
  46162. /**
  46163. * Gets the skybox material created by the helper.
  46164. */
  46165. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46166. private _ground;
  46167. /**
  46168. * Gets the ground mesh created by the helper.
  46169. */
  46170. readonly ground: Nullable<Mesh>;
  46171. private _groundTexture;
  46172. /**
  46173. * Gets the ground texture created by the helper.
  46174. */
  46175. readonly groundTexture: Nullable<BaseTexture>;
  46176. private _groundMirror;
  46177. /**
  46178. * Gets the ground mirror created by the helper.
  46179. */
  46180. readonly groundMirror: Nullable<MirrorTexture>;
  46181. /**
  46182. * Gets the ground mirror render list to helps pushing the meshes
  46183. * you wish in the ground reflection.
  46184. */
  46185. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46186. private _groundMaterial;
  46187. /**
  46188. * Gets the ground material created by the helper.
  46189. */
  46190. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46191. /**
  46192. * Stores the creation options.
  46193. */
  46194. private readonly _scene;
  46195. private _options;
  46196. /**
  46197. * This observable will be notified with any error during the creation of the environment,
  46198. * mainly texture creation errors.
  46199. */
  46200. onErrorObservable: Observable<{
  46201. message?: string;
  46202. exception?: any;
  46203. }>;
  46204. /**
  46205. * constructor
  46206. * @param options Defines the options we want to customize the helper
  46207. * @param scene The scene to add the material to
  46208. */
  46209. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46210. /**
  46211. * Updates the background according to the new options
  46212. * @param options
  46213. */
  46214. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46215. /**
  46216. * Sets the primary color of all the available elements.
  46217. * @param color the main color to affect to the ground and the background
  46218. */
  46219. setMainColor(color: Color3): void;
  46220. /**
  46221. * Setup the image processing according to the specified options.
  46222. */
  46223. private _setupImageProcessing;
  46224. /**
  46225. * Setup the environment texture according to the specified options.
  46226. */
  46227. private _setupEnvironmentTexture;
  46228. /**
  46229. * Setup the background according to the specified options.
  46230. */
  46231. private _setupBackground;
  46232. /**
  46233. * Get the scene sizes according to the setup.
  46234. */
  46235. private _getSceneSize;
  46236. /**
  46237. * Setup the ground according to the specified options.
  46238. */
  46239. private _setupGround;
  46240. /**
  46241. * Setup the ground material according to the specified options.
  46242. */
  46243. private _setupGroundMaterial;
  46244. /**
  46245. * Setup the ground diffuse texture according to the specified options.
  46246. */
  46247. private _setupGroundDiffuseTexture;
  46248. /**
  46249. * Setup the ground mirror texture according to the specified options.
  46250. */
  46251. private _setupGroundMirrorTexture;
  46252. /**
  46253. * Setup the ground to receive the mirror texture.
  46254. */
  46255. private _setupMirrorInGroundMaterial;
  46256. /**
  46257. * Setup the skybox according to the specified options.
  46258. */
  46259. private _setupSkybox;
  46260. /**
  46261. * Setup the skybox material according to the specified options.
  46262. */
  46263. private _setupSkyboxMaterial;
  46264. /**
  46265. * Setup the skybox reflection texture according to the specified options.
  46266. */
  46267. private _setupSkyboxReflectionTexture;
  46268. private _errorHandler;
  46269. /**
  46270. * Dispose all the elements created by the Helper.
  46271. */
  46272. dispose(): void;
  46273. }
  46274. }
  46275. declare module BABYLON {
  46276. /**
  46277. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46278. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46279. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46280. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46281. */
  46282. export class PhotoDome extends TransformNode {
  46283. /**
  46284. * Define the image as a Monoscopic panoramic 360 image.
  46285. */
  46286. static readonly MODE_MONOSCOPIC: number;
  46287. /**
  46288. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46289. */
  46290. static readonly MODE_TOPBOTTOM: number;
  46291. /**
  46292. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46293. */
  46294. static readonly MODE_SIDEBYSIDE: number;
  46295. private _useDirectMapping;
  46296. /**
  46297. * The texture being displayed on the sphere
  46298. */
  46299. protected _photoTexture: Texture;
  46300. /**
  46301. * Gets or sets the texture being displayed on the sphere
  46302. */
  46303. photoTexture: Texture;
  46304. /**
  46305. * Observable raised when an error occured while loading the 360 image
  46306. */
  46307. onLoadErrorObservable: Observable<string>;
  46308. /**
  46309. * The skybox material
  46310. */
  46311. protected _material: BackgroundMaterial;
  46312. /**
  46313. * The surface used for the skybox
  46314. */
  46315. protected _mesh: Mesh;
  46316. /**
  46317. * Gets the mesh used for the skybox.
  46318. */
  46319. readonly mesh: Mesh;
  46320. /**
  46321. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46322. * Also see the options.resolution property.
  46323. */
  46324. fovMultiplier: number;
  46325. private _imageMode;
  46326. /**
  46327. * Gets or set the current video mode for the video. It can be:
  46328. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46329. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46330. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46331. */
  46332. imageMode: number;
  46333. /**
  46334. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46335. * @param name Element's name, child elements will append suffixes for their own names.
  46336. * @param urlsOfPhoto defines the url of the photo to display
  46337. * @param options defines an object containing optional or exposed sub element properties
  46338. * @param onError defines a callback called when an error occured while loading the texture
  46339. */
  46340. constructor(name: string, urlOfPhoto: string, options: {
  46341. resolution?: number;
  46342. size?: number;
  46343. useDirectMapping?: boolean;
  46344. faceForward?: boolean;
  46345. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46346. private _onBeforeCameraRenderObserver;
  46347. private _changeImageMode;
  46348. /**
  46349. * Releases resources associated with this node.
  46350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46352. */
  46353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46354. }
  46355. }
  46356. declare module BABYLON {
  46357. /**
  46358. * Class used to host RGBD texture specific utilities
  46359. */
  46360. export class RGBDTextureTools {
  46361. /**
  46362. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46363. * @param texture the texture to expand.
  46364. */
  46365. static ExpandRGBDTexture(texture: Texture): void;
  46366. }
  46367. }
  46368. declare module BABYLON {
  46369. /**
  46370. * Class used to host texture specific utilities
  46371. */
  46372. export class BRDFTextureTools {
  46373. /**
  46374. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46375. * @param scene defines the hosting scene
  46376. * @returns the environment BRDF texture
  46377. */
  46378. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46379. private static _environmentBRDFBase64Texture;
  46380. }
  46381. }
  46382. declare module BABYLON {
  46383. /**
  46384. * @hidden
  46385. */
  46386. export interface IMaterialClearCoatDefines {
  46387. CLEARCOAT: boolean;
  46388. CLEARCOAT_DEFAULTIOR: boolean;
  46389. CLEARCOAT_TEXTURE: boolean;
  46390. CLEARCOAT_TEXTUREDIRECTUV: number;
  46391. CLEARCOAT_BUMP: boolean;
  46392. CLEARCOAT_BUMPDIRECTUV: number;
  46393. CLEARCOAT_TINT: boolean;
  46394. CLEARCOAT_TINT_TEXTURE: boolean;
  46395. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46396. /** @hidden */
  46397. _areTexturesDirty: boolean;
  46398. }
  46399. /**
  46400. * Define the code related to the clear coat parameters of the pbr material.
  46401. */
  46402. export class PBRClearCoatConfiguration {
  46403. /**
  46404. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46405. * The default fits with a polyurethane material.
  46406. */
  46407. private static readonly _DefaultIndexOfRefraction;
  46408. private _isEnabled;
  46409. /**
  46410. * Defines if the clear coat is enabled in the material.
  46411. */
  46412. isEnabled: boolean;
  46413. /**
  46414. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46415. */
  46416. intensity: number;
  46417. /**
  46418. * Defines the clear coat layer roughness.
  46419. */
  46420. roughness: number;
  46421. private _indexOfRefraction;
  46422. /**
  46423. * Defines the index of refraction of the clear coat.
  46424. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46425. * The default fits with a polyurethane material.
  46426. * Changing the default value is more performance intensive.
  46427. */
  46428. indexOfRefraction: number;
  46429. private _texture;
  46430. /**
  46431. * Stores the clear coat values in a texture.
  46432. */
  46433. texture: Nullable<BaseTexture>;
  46434. private _bumpTexture;
  46435. /**
  46436. * Define the clear coat specific bump texture.
  46437. */
  46438. bumpTexture: Nullable<BaseTexture>;
  46439. private _isTintEnabled;
  46440. /**
  46441. * Defines if the clear coat tint is enabled in the material.
  46442. */
  46443. isTintEnabled: boolean;
  46444. /**
  46445. * Defines the clear coat tint of the material.
  46446. * This is only use if tint is enabled
  46447. */
  46448. tintColor: Color3;
  46449. /**
  46450. * Defines the distance at which the tint color should be found in the
  46451. * clear coat media.
  46452. * This is only use if tint is enabled
  46453. */
  46454. tintColorAtDistance: number;
  46455. /**
  46456. * Defines the clear coat layer thickness.
  46457. * This is only use if tint is enabled
  46458. */
  46459. tintThickness: number;
  46460. private _tintTexture;
  46461. /**
  46462. * Stores the clear tint values in a texture.
  46463. * rgb is tint
  46464. * a is a thickness factor
  46465. */
  46466. tintTexture: Nullable<BaseTexture>;
  46467. /** @hidden */
  46468. private _internalMarkAllSubMeshesAsTexturesDirty;
  46469. /** @hidden */
  46470. _markAllSubMeshesAsTexturesDirty(): void;
  46471. /**
  46472. * Instantiate a new istance of clear coat configuration.
  46473. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46474. */
  46475. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46476. /**
  46477. * Gets wehter the submesh is ready to be used or not.
  46478. * @param defines the list of "defines" to update.
  46479. * @param scene defines the scene the material belongs to.
  46480. * @param engine defines the engine the material belongs to.
  46481. * @param disableBumpMap defines wether the material disables bump or not.
  46482. * @returns - boolean indicating that the submesh is ready or not.
  46483. */
  46484. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46485. /**
  46486. * Checks to see if a texture is used in the material.
  46487. * @param defines the list of "defines" to update.
  46488. * @param scene defines the scene to the material belongs to.
  46489. */
  46490. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46491. /**
  46492. * Binds the material data.
  46493. * @param uniformBuffer defines the Uniform buffer to fill in.
  46494. * @param scene defines the scene the material belongs to.
  46495. * @param engine defines the engine the material belongs to.
  46496. * @param disableBumpMap defines wether the material disables bump or not.
  46497. * @param isFrozen defines wether the material is frozen or not.
  46498. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46499. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46500. */
  46501. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46502. /**
  46503. * Checks to see if a texture is used in the material.
  46504. * @param texture - Base texture to use.
  46505. * @returns - Boolean specifying if a texture is used in the material.
  46506. */
  46507. hasTexture(texture: BaseTexture): boolean;
  46508. /**
  46509. * Returns an array of the actively used textures.
  46510. * @param activeTextures Array of BaseTextures
  46511. */
  46512. getActiveTextures(activeTextures: BaseTexture[]): void;
  46513. /**
  46514. * Returns the animatable textures.
  46515. * @param animatables Array of animatable textures.
  46516. */
  46517. getAnimatables(animatables: IAnimatable[]): void;
  46518. /**
  46519. * Disposes the resources of the material.
  46520. * @param forceDisposeTextures - Forces the disposal of all textures.
  46521. */
  46522. dispose(forceDisposeTextures?: boolean): void;
  46523. /**
  46524. * Get the current class name of the texture useful for serialization or dynamic coding.
  46525. * @returns "PBRClearCoatConfiguration"
  46526. */
  46527. getClassName(): string;
  46528. /**
  46529. * Add fallbacks to the effect fallbacks list.
  46530. * @param defines defines the Base texture to use.
  46531. * @param fallbacks defines the current fallback list.
  46532. * @param currentRank defines the current fallback rank.
  46533. * @returns the new fallback rank.
  46534. */
  46535. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46536. /**
  46537. * Add the required uniforms to the current list.
  46538. * @param uniforms defines the current uniform list.
  46539. */
  46540. static AddUniforms(uniforms: string[]): void;
  46541. /**
  46542. * Add the required samplers to the current list.
  46543. * @param samplers defines the current sampler list.
  46544. */
  46545. static AddSamplers(samplers: string[]): void;
  46546. /**
  46547. * Add the required uniforms to the current buffer.
  46548. * @param uniformBuffer defines the current uniform buffer.
  46549. */
  46550. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46551. /**
  46552. * Makes a duplicate of the current configuration into another one.
  46553. * @param clearCoatConfiguration define the config where to copy the info
  46554. */
  46555. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46556. /**
  46557. * Serializes this clear coat configuration.
  46558. * @returns - An object with the serialized config.
  46559. */
  46560. serialize(): any;
  46561. /**
  46562. * Parses a anisotropy Configuration from a serialized object.
  46563. * @param source - Serialized object.
  46564. * @param scene Defines the scene we are parsing for
  46565. * @param rootUrl Defines the rootUrl to load from
  46566. */
  46567. parse(source: any, scene: Scene, rootUrl: string): void;
  46568. }
  46569. }
  46570. declare module BABYLON {
  46571. /**
  46572. * @hidden
  46573. */
  46574. export interface IMaterialAnisotropicDefines {
  46575. ANISOTROPIC: boolean;
  46576. ANISOTROPIC_TEXTURE: boolean;
  46577. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46578. MAINUV1: boolean;
  46579. _areTexturesDirty: boolean;
  46580. _needUVs: boolean;
  46581. }
  46582. /**
  46583. * Define the code related to the anisotropic parameters of the pbr material.
  46584. */
  46585. export class PBRAnisotropicConfiguration {
  46586. private _isEnabled;
  46587. /**
  46588. * Defines if the anisotropy is enabled in the material.
  46589. */
  46590. isEnabled: boolean;
  46591. /**
  46592. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46593. */
  46594. intensity: number;
  46595. /**
  46596. * Defines if the effect is along the tangents, bitangents or in between.
  46597. * By default, the effect is "strectching" the highlights along the tangents.
  46598. */
  46599. direction: Vector2;
  46600. private _texture;
  46601. /**
  46602. * Stores the anisotropy values in a texture.
  46603. * rg is direction (like normal from -1 to 1)
  46604. * b is a intensity
  46605. */
  46606. texture: Nullable<BaseTexture>;
  46607. /** @hidden */
  46608. private _internalMarkAllSubMeshesAsTexturesDirty;
  46609. /** @hidden */
  46610. _markAllSubMeshesAsTexturesDirty(): void;
  46611. /**
  46612. * Instantiate a new istance of anisotropy configuration.
  46613. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46614. */
  46615. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46616. /**
  46617. * Specifies that the submesh is ready to be used.
  46618. * @param defines the list of "defines" to update.
  46619. * @param scene defines the scene the material belongs to.
  46620. * @returns - boolean indicating that the submesh is ready or not.
  46621. */
  46622. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46623. /**
  46624. * Checks to see if a texture is used in the material.
  46625. * @param defines the list of "defines" to update.
  46626. * @param mesh the mesh we are preparing the defines for.
  46627. * @param scene defines the scene the material belongs to.
  46628. */
  46629. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46630. /**
  46631. * Binds the material data.
  46632. * @param uniformBuffer defines the Uniform buffer to fill in.
  46633. * @param scene defines the scene the material belongs to.
  46634. * @param isFrozen defines wether the material is frozen or not.
  46635. */
  46636. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46637. /**
  46638. * Checks to see if a texture is used in the material.
  46639. * @param texture - Base texture to use.
  46640. * @returns - Boolean specifying if a texture is used in the material.
  46641. */
  46642. hasTexture(texture: BaseTexture): boolean;
  46643. /**
  46644. * Returns an array of the actively used textures.
  46645. * @param activeTextures Array of BaseTextures
  46646. */
  46647. getActiveTextures(activeTextures: BaseTexture[]): void;
  46648. /**
  46649. * Returns the animatable textures.
  46650. * @param animatables Array of animatable textures.
  46651. */
  46652. getAnimatables(animatables: IAnimatable[]): void;
  46653. /**
  46654. * Disposes the resources of the material.
  46655. * @param forceDisposeTextures - Forces the disposal of all textures.
  46656. */
  46657. dispose(forceDisposeTextures?: boolean): void;
  46658. /**
  46659. * Get the current class name of the texture useful for serialization or dynamic coding.
  46660. * @returns "PBRAnisotropicConfiguration"
  46661. */
  46662. getClassName(): string;
  46663. /**
  46664. * Add fallbacks to the effect fallbacks list.
  46665. * @param defines defines the Base texture to use.
  46666. * @param fallbacks defines the current fallback list.
  46667. * @param currentRank defines the current fallback rank.
  46668. * @returns the new fallback rank.
  46669. */
  46670. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46671. /**
  46672. * Add the required uniforms to the current list.
  46673. * @param uniforms defines the current uniform list.
  46674. */
  46675. static AddUniforms(uniforms: string[]): void;
  46676. /**
  46677. * Add the required uniforms to the current buffer.
  46678. * @param uniformBuffer defines the current uniform buffer.
  46679. */
  46680. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46681. /**
  46682. * Add the required samplers to the current list.
  46683. * @param samplers defines the current sampler list.
  46684. */
  46685. static AddSamplers(samplers: string[]): void;
  46686. /**
  46687. * Makes a duplicate of the current configuration into another one.
  46688. * @param anisotropicConfiguration define the config where to copy the info
  46689. */
  46690. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46691. /**
  46692. * Serializes this anisotropy configuration.
  46693. * @returns - An object with the serialized config.
  46694. */
  46695. serialize(): any;
  46696. /**
  46697. * Parses a anisotropy Configuration from a serialized object.
  46698. * @param source - Serialized object.
  46699. * @param scene Defines the scene we are parsing for
  46700. * @param rootUrl Defines the rootUrl to load from
  46701. */
  46702. parse(source: any, scene: Scene, rootUrl: string): void;
  46703. }
  46704. }
  46705. declare module BABYLON {
  46706. /**
  46707. * @hidden
  46708. */
  46709. export interface IMaterialBRDFDefines {
  46710. BRDF_V_HEIGHT_CORRELATED: boolean;
  46711. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46712. SPHERICAL_HARMONICS: boolean;
  46713. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46714. /** @hidden */
  46715. _areMiscDirty: boolean;
  46716. }
  46717. /**
  46718. * Define the code related to the BRDF parameters of the pbr material.
  46719. */
  46720. export class PBRBRDFConfiguration {
  46721. /**
  46722. * Default value used for the energy conservation.
  46723. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46724. */
  46725. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46726. /**
  46727. * Default value used for the Smith Visibility Height Correlated mode.
  46728. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46729. */
  46730. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46731. /**
  46732. * Default value used for the IBL diffuse part.
  46733. * This can help switching back to the polynomials mode globally which is a tiny bit
  46734. * less GPU intensive at the drawback of a lower quality.
  46735. */
  46736. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46737. /**
  46738. * Default value used for activating energy conservation for the specular workflow.
  46739. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46740. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46741. */
  46742. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46743. private _useEnergyConservation;
  46744. /**
  46745. * Defines if the material uses energy conservation.
  46746. */
  46747. useEnergyConservation: boolean;
  46748. private _useSmithVisibilityHeightCorrelated;
  46749. /**
  46750. * LEGACY Mode set to false
  46751. * Defines if the material uses height smith correlated visibility term.
  46752. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46753. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46754. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46755. * Not relying on height correlated will also disable energy conservation.
  46756. */
  46757. useSmithVisibilityHeightCorrelated: boolean;
  46758. private _useSphericalHarmonics;
  46759. /**
  46760. * LEGACY Mode set to false
  46761. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46762. * diffuse part of the IBL.
  46763. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46764. * to the ground truth.
  46765. */
  46766. useSphericalHarmonics: boolean;
  46767. private _useSpecularGlossinessInputEnergyConservation;
  46768. /**
  46769. * Defines if the material uses energy conservation, when the specular workflow is active.
  46770. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46771. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46772. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46773. */
  46774. useSpecularGlossinessInputEnergyConservation: boolean;
  46775. /** @hidden */
  46776. private _internalMarkAllSubMeshesAsMiscDirty;
  46777. /** @hidden */
  46778. _markAllSubMeshesAsMiscDirty(): void;
  46779. /**
  46780. * Instantiate a new istance of clear coat configuration.
  46781. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46782. */
  46783. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46784. /**
  46785. * Checks to see if a texture is used in the material.
  46786. * @param defines the list of "defines" to update.
  46787. */
  46788. prepareDefines(defines: IMaterialBRDFDefines): void;
  46789. /**
  46790. * Get the current class name of the texture useful for serialization or dynamic coding.
  46791. * @returns "PBRClearCoatConfiguration"
  46792. */
  46793. getClassName(): string;
  46794. /**
  46795. * Makes a duplicate of the current configuration into another one.
  46796. * @param brdfConfiguration define the config where to copy the info
  46797. */
  46798. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46799. /**
  46800. * Serializes this BRDF configuration.
  46801. * @returns - An object with the serialized config.
  46802. */
  46803. serialize(): any;
  46804. /**
  46805. * Parses a anisotropy Configuration from a serialized object.
  46806. * @param source - Serialized object.
  46807. * @param scene Defines the scene we are parsing for
  46808. * @param rootUrl Defines the rootUrl to load from
  46809. */
  46810. parse(source: any, scene: Scene, rootUrl: string): void;
  46811. }
  46812. }
  46813. declare module BABYLON {
  46814. /**
  46815. * @hidden
  46816. */
  46817. export interface IMaterialSheenDefines {
  46818. SHEEN: boolean;
  46819. SHEEN_TEXTURE: boolean;
  46820. SHEEN_TEXTUREDIRECTUV: number;
  46821. SHEEN_LINKWITHALBEDO: boolean;
  46822. /** @hidden */
  46823. _areTexturesDirty: boolean;
  46824. }
  46825. /**
  46826. * Define the code related to the Sheen parameters of the pbr material.
  46827. */
  46828. export class PBRSheenConfiguration {
  46829. private _isEnabled;
  46830. /**
  46831. * Defines if the material uses sheen.
  46832. */
  46833. isEnabled: boolean;
  46834. private _linkSheenWithAlbedo;
  46835. /**
  46836. * Defines if the sheen is linked to the sheen color.
  46837. */
  46838. linkSheenWithAlbedo: boolean;
  46839. /**
  46840. * Defines the sheen intensity.
  46841. */
  46842. intensity: number;
  46843. /**
  46844. * Defines the sheen color.
  46845. */
  46846. color: Color3;
  46847. private _texture;
  46848. /**
  46849. * Stores the sheen tint values in a texture.
  46850. * rgb is tint
  46851. * a is a intensity
  46852. */
  46853. texture: Nullable<BaseTexture>;
  46854. /** @hidden */
  46855. private _internalMarkAllSubMeshesAsTexturesDirty;
  46856. /** @hidden */
  46857. _markAllSubMeshesAsTexturesDirty(): void;
  46858. /**
  46859. * Instantiate a new istance of clear coat configuration.
  46860. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46861. */
  46862. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46863. /**
  46864. * Specifies that the submesh is ready to be used.
  46865. * @param defines the list of "defines" to update.
  46866. * @param scene defines the scene the material belongs to.
  46867. * @returns - boolean indicating that the submesh is ready or not.
  46868. */
  46869. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46870. /**
  46871. * Checks to see if a texture is used in the material.
  46872. * @param defines the list of "defines" to update.
  46873. * @param scene defines the scene the material belongs to.
  46874. */
  46875. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46876. /**
  46877. * Binds the material data.
  46878. * @param uniformBuffer defines the Uniform buffer to fill in.
  46879. * @param scene defines the scene the material belongs to.
  46880. * @param isFrozen defines wether the material is frozen or not.
  46881. */
  46882. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46883. /**
  46884. * Checks to see if a texture is used in the material.
  46885. * @param texture - Base texture to use.
  46886. * @returns - Boolean specifying if a texture is used in the material.
  46887. */
  46888. hasTexture(texture: BaseTexture): boolean;
  46889. /**
  46890. * Returns an array of the actively used textures.
  46891. * @param activeTextures Array of BaseTextures
  46892. */
  46893. getActiveTextures(activeTextures: BaseTexture[]): void;
  46894. /**
  46895. * Returns the animatable textures.
  46896. * @param animatables Array of animatable textures.
  46897. */
  46898. getAnimatables(animatables: IAnimatable[]): void;
  46899. /**
  46900. * Disposes the resources of the material.
  46901. * @param forceDisposeTextures - Forces the disposal of all textures.
  46902. */
  46903. dispose(forceDisposeTextures?: boolean): void;
  46904. /**
  46905. * Get the current class name of the texture useful for serialization or dynamic coding.
  46906. * @returns "PBRSheenConfiguration"
  46907. */
  46908. getClassName(): string;
  46909. /**
  46910. * Add fallbacks to the effect fallbacks list.
  46911. * @param defines defines the Base texture to use.
  46912. * @param fallbacks defines the current fallback list.
  46913. * @param currentRank defines the current fallback rank.
  46914. * @returns the new fallback rank.
  46915. */
  46916. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46917. /**
  46918. * Add the required uniforms to the current list.
  46919. * @param uniforms defines the current uniform list.
  46920. */
  46921. static AddUniforms(uniforms: string[]): void;
  46922. /**
  46923. * Add the required uniforms to the current buffer.
  46924. * @param uniformBuffer defines the current uniform buffer.
  46925. */
  46926. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46927. /**
  46928. * Add the required samplers to the current list.
  46929. * @param samplers defines the current sampler list.
  46930. */
  46931. static AddSamplers(samplers: string[]): void;
  46932. /**
  46933. * Makes a duplicate of the current configuration into another one.
  46934. * @param sheenConfiguration define the config where to copy the info
  46935. */
  46936. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46937. /**
  46938. * Serializes this BRDF configuration.
  46939. * @returns - An object with the serialized config.
  46940. */
  46941. serialize(): any;
  46942. /**
  46943. * Parses a anisotropy Configuration from a serialized object.
  46944. * @param source - Serialized object.
  46945. * @param scene Defines the scene we are parsing for
  46946. * @param rootUrl Defines the rootUrl to load from
  46947. */
  46948. parse(source: any, scene: Scene, rootUrl: string): void;
  46949. }
  46950. }
  46951. declare module BABYLON {
  46952. /**
  46953. * @hidden
  46954. */
  46955. export interface IMaterialSubSurfaceDefines {
  46956. SUBSURFACE: boolean;
  46957. SS_REFRACTION: boolean;
  46958. SS_TRANSLUCENCY: boolean;
  46959. SS_SCATERRING: boolean;
  46960. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46961. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46962. SS_REFRACTIONMAP_3D: boolean;
  46963. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46964. SS_LODINREFRACTIONALPHA: boolean;
  46965. SS_GAMMAREFRACTION: boolean;
  46966. SS_RGBDREFRACTION: boolean;
  46967. SS_LINEARSPECULARREFRACTION: boolean;
  46968. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46969. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46970. /** @hidden */
  46971. _areTexturesDirty: boolean;
  46972. }
  46973. /**
  46974. * Define the code related to the sub surface parameters of the pbr material.
  46975. */
  46976. export class PBRSubSurfaceConfiguration {
  46977. private _isRefractionEnabled;
  46978. /**
  46979. * Defines if the refraction is enabled in the material.
  46980. */
  46981. isRefractionEnabled: boolean;
  46982. private _isTranslucencyEnabled;
  46983. /**
  46984. * Defines if the translucency is enabled in the material.
  46985. */
  46986. isTranslucencyEnabled: boolean;
  46987. private _isScatteringEnabled;
  46988. /**
  46989. * Defines the refraction intensity of the material.
  46990. * The refraction when enabled replaces the Diffuse part of the material.
  46991. * The intensity helps transitionning between diffuse and refraction.
  46992. */
  46993. refractionIntensity: number;
  46994. /**
  46995. * Defines the translucency intensity of the material.
  46996. * When translucency has been enabled, this defines how much of the "translucency"
  46997. * is addded to the diffuse part of the material.
  46998. */
  46999. translucencyIntensity: number;
  47000. /**
  47001. * Defines the scattering intensity of the material.
  47002. * When scattering has been enabled, this defines how much of the "scattered light"
  47003. * is addded to the diffuse part of the material.
  47004. */
  47005. scatteringIntensity: number;
  47006. private _thicknessTexture;
  47007. /**
  47008. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47009. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47010. * 0 would mean minimumThickness
  47011. * 1 would mean maximumThickness
  47012. * The other channels might be use as a mask to vary the different effects intensity.
  47013. */
  47014. thicknessTexture: Nullable<BaseTexture>;
  47015. private _refractionTexture;
  47016. /**
  47017. * Defines the texture to use for refraction.
  47018. */
  47019. refractionTexture: Nullable<BaseTexture>;
  47020. private _indexOfRefraction;
  47021. /**
  47022. * Defines the index of refraction used in the material.
  47023. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47024. */
  47025. indexOfRefraction: number;
  47026. private _invertRefractionY;
  47027. /**
  47028. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47029. */
  47030. invertRefractionY: boolean;
  47031. private _linkRefractionWithTransparency;
  47032. /**
  47033. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47034. * Materials half opaque for instance using refraction could benefit from this control.
  47035. */
  47036. linkRefractionWithTransparency: boolean;
  47037. /**
  47038. * Defines the minimum thickness stored in the thickness map.
  47039. * If no thickness map is defined, this value will be used to simulate thickness.
  47040. */
  47041. minimumThickness: number;
  47042. /**
  47043. * Defines the maximum thickness stored in the thickness map.
  47044. */
  47045. maximumThickness: number;
  47046. /**
  47047. * Defines the volume tint of the material.
  47048. * This is used for both translucency and scattering.
  47049. */
  47050. tintColor: Color3;
  47051. /**
  47052. * Defines the distance at which the tint color should be found in the media.
  47053. * This is used for refraction only.
  47054. */
  47055. tintColorAtDistance: number;
  47056. /**
  47057. * Defines how far each channel transmit through the media.
  47058. * It is defined as a color to simplify it selection.
  47059. */
  47060. diffusionDistance: Color3;
  47061. private _useMaskFromThicknessTexture;
  47062. /**
  47063. * Stores the intensity of the different subsurface effects in the thickness texture.
  47064. * * the green channel is the translucency intensity.
  47065. * * the blue channel is the scattering intensity.
  47066. * * the alpha channel is the refraction intensity.
  47067. */
  47068. useMaskFromThicknessTexture: boolean;
  47069. /** @hidden */
  47070. private _internalMarkAllSubMeshesAsTexturesDirty;
  47071. /** @hidden */
  47072. _markAllSubMeshesAsTexturesDirty(): void;
  47073. /**
  47074. * Instantiate a new istance of sub surface configuration.
  47075. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47076. */
  47077. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47078. /**
  47079. * Gets wehter the submesh is ready to be used or not.
  47080. * @param defines the list of "defines" to update.
  47081. * @param scene defines the scene the material belongs to.
  47082. * @returns - boolean indicating that the submesh is ready or not.
  47083. */
  47084. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47085. /**
  47086. * Checks to see if a texture is used in the material.
  47087. * @param defines the list of "defines" to update.
  47088. * @param scene defines the scene to the material belongs to.
  47089. */
  47090. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47091. /**
  47092. * Binds the material data.
  47093. * @param uniformBuffer defines the Uniform buffer to fill in.
  47094. * @param scene defines the scene the material belongs to.
  47095. * @param engine defines the engine the material belongs to.
  47096. * @param isFrozen defines wether the material is frozen or not.
  47097. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47098. */
  47099. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47100. /**
  47101. * Unbinds the material from the mesh.
  47102. * @param activeEffect defines the effect that should be unbound from.
  47103. * @returns true if unbound, otherwise false
  47104. */
  47105. unbind(activeEffect: Effect): boolean;
  47106. /**
  47107. * Returns the texture used for refraction or null if none is used.
  47108. * @param scene defines the scene the material belongs to.
  47109. * @returns - Refraction texture if present. If no refraction texture and refraction
  47110. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47111. */
  47112. private _getRefractionTexture;
  47113. /**
  47114. * Returns true if alpha blending should be disabled.
  47115. */
  47116. readonly disableAlphaBlending: boolean;
  47117. /**
  47118. * Fills the list of render target textures.
  47119. * @param renderTargets the list of render targets to update
  47120. */
  47121. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47122. /**
  47123. * Checks to see if a texture is used in the material.
  47124. * @param texture - Base texture to use.
  47125. * @returns - Boolean specifying if a texture is used in the material.
  47126. */
  47127. hasTexture(texture: BaseTexture): boolean;
  47128. /**
  47129. * Gets a boolean indicating that current material needs to register RTT
  47130. * @returns true if this uses a render target otherwise false.
  47131. */
  47132. hasRenderTargetTextures(): boolean;
  47133. /**
  47134. * Returns an array of the actively used textures.
  47135. * @param activeTextures Array of BaseTextures
  47136. */
  47137. getActiveTextures(activeTextures: BaseTexture[]): void;
  47138. /**
  47139. * Returns the animatable textures.
  47140. * @param animatables Array of animatable textures.
  47141. */
  47142. getAnimatables(animatables: IAnimatable[]): void;
  47143. /**
  47144. * Disposes the resources of the material.
  47145. * @param forceDisposeTextures - Forces the disposal of all textures.
  47146. */
  47147. dispose(forceDisposeTextures?: boolean): void;
  47148. /**
  47149. * Get the current class name of the texture useful for serialization or dynamic coding.
  47150. * @returns "PBRSubSurfaceConfiguration"
  47151. */
  47152. getClassName(): string;
  47153. /**
  47154. * Add fallbacks to the effect fallbacks list.
  47155. * @param defines defines the Base texture to use.
  47156. * @param fallbacks defines the current fallback list.
  47157. * @param currentRank defines the current fallback rank.
  47158. * @returns the new fallback rank.
  47159. */
  47160. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47161. /**
  47162. * Add the required uniforms to the current list.
  47163. * @param uniforms defines the current uniform list.
  47164. */
  47165. static AddUniforms(uniforms: string[]): void;
  47166. /**
  47167. * Add the required samplers to the current list.
  47168. * @param samplers defines the current sampler list.
  47169. */
  47170. static AddSamplers(samplers: string[]): void;
  47171. /**
  47172. * Add the required uniforms to the current buffer.
  47173. * @param uniformBuffer defines the current uniform buffer.
  47174. */
  47175. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47176. /**
  47177. * Makes a duplicate of the current configuration into another one.
  47178. * @param configuration define the config where to copy the info
  47179. */
  47180. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47181. /**
  47182. * Serializes this Sub Surface configuration.
  47183. * @returns - An object with the serialized config.
  47184. */
  47185. serialize(): any;
  47186. /**
  47187. * Parses a anisotropy Configuration from a serialized object.
  47188. * @param source - Serialized object.
  47189. * @param scene Defines the scene we are parsing for
  47190. * @param rootUrl Defines the rootUrl to load from
  47191. */
  47192. parse(source: any, scene: Scene, rootUrl: string): void;
  47193. }
  47194. }
  47195. declare module BABYLON {
  47196. /** @hidden */
  47197. export var pbrFragmentDeclaration: {
  47198. name: string;
  47199. shader: string;
  47200. };
  47201. }
  47202. declare module BABYLON {
  47203. /** @hidden */
  47204. export var pbrUboDeclaration: {
  47205. name: string;
  47206. shader: string;
  47207. };
  47208. }
  47209. declare module BABYLON {
  47210. /** @hidden */
  47211. export var pbrFragmentExtraDeclaration: {
  47212. name: string;
  47213. shader: string;
  47214. };
  47215. }
  47216. declare module BABYLON {
  47217. /** @hidden */
  47218. export var pbrFragmentSamplersDeclaration: {
  47219. name: string;
  47220. shader: string;
  47221. };
  47222. }
  47223. declare module BABYLON {
  47224. /** @hidden */
  47225. export var pbrHelperFunctions: {
  47226. name: string;
  47227. shader: string;
  47228. };
  47229. }
  47230. declare module BABYLON {
  47231. /** @hidden */
  47232. export var harmonicsFunctions: {
  47233. name: string;
  47234. shader: string;
  47235. };
  47236. }
  47237. declare module BABYLON {
  47238. /** @hidden */
  47239. export var pbrDirectLightingSetupFunctions: {
  47240. name: string;
  47241. shader: string;
  47242. };
  47243. }
  47244. declare module BABYLON {
  47245. /** @hidden */
  47246. export var pbrDirectLightingFalloffFunctions: {
  47247. name: string;
  47248. shader: string;
  47249. };
  47250. }
  47251. declare module BABYLON {
  47252. /** @hidden */
  47253. export var pbrBRDFFunctions: {
  47254. name: string;
  47255. shader: string;
  47256. };
  47257. }
  47258. declare module BABYLON {
  47259. /** @hidden */
  47260. export var pbrDirectLightingFunctions: {
  47261. name: string;
  47262. shader: string;
  47263. };
  47264. }
  47265. declare module BABYLON {
  47266. /** @hidden */
  47267. export var pbrIBLFunctions: {
  47268. name: string;
  47269. shader: string;
  47270. };
  47271. }
  47272. declare module BABYLON {
  47273. /** @hidden */
  47274. export var pbrDebug: {
  47275. name: string;
  47276. shader: string;
  47277. };
  47278. }
  47279. declare module BABYLON {
  47280. /** @hidden */
  47281. export var pbrPixelShader: {
  47282. name: string;
  47283. shader: string;
  47284. };
  47285. }
  47286. declare module BABYLON {
  47287. /** @hidden */
  47288. export var pbrVertexDeclaration: {
  47289. name: string;
  47290. shader: string;
  47291. };
  47292. }
  47293. declare module BABYLON {
  47294. /** @hidden */
  47295. export var pbrVertexShader: {
  47296. name: string;
  47297. shader: string;
  47298. };
  47299. }
  47300. declare module BABYLON {
  47301. /**
  47302. * Manages the defines for the PBR Material.
  47303. * @hidden
  47304. */
  47305. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47306. PBR: boolean;
  47307. MAINUV1: boolean;
  47308. MAINUV2: boolean;
  47309. UV1: boolean;
  47310. UV2: boolean;
  47311. ALBEDO: boolean;
  47312. ALBEDODIRECTUV: number;
  47313. VERTEXCOLOR: boolean;
  47314. AMBIENT: boolean;
  47315. AMBIENTDIRECTUV: number;
  47316. AMBIENTINGRAYSCALE: boolean;
  47317. OPACITY: boolean;
  47318. VERTEXALPHA: boolean;
  47319. OPACITYDIRECTUV: number;
  47320. OPACITYRGB: boolean;
  47321. ALPHATEST: boolean;
  47322. DEPTHPREPASS: boolean;
  47323. ALPHABLEND: boolean;
  47324. ALPHAFROMALBEDO: boolean;
  47325. ALPHATESTVALUE: string;
  47326. SPECULAROVERALPHA: boolean;
  47327. RADIANCEOVERALPHA: boolean;
  47328. ALPHAFRESNEL: boolean;
  47329. LINEARALPHAFRESNEL: boolean;
  47330. PREMULTIPLYALPHA: boolean;
  47331. EMISSIVE: boolean;
  47332. EMISSIVEDIRECTUV: number;
  47333. REFLECTIVITY: boolean;
  47334. REFLECTIVITYDIRECTUV: number;
  47335. SPECULARTERM: boolean;
  47336. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47337. MICROSURFACEAUTOMATIC: boolean;
  47338. LODBASEDMICROSFURACE: boolean;
  47339. MICROSURFACEMAP: boolean;
  47340. MICROSURFACEMAPDIRECTUV: number;
  47341. METALLICWORKFLOW: boolean;
  47342. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47343. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47344. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47345. AOSTOREINMETALMAPRED: boolean;
  47346. ENVIRONMENTBRDF: boolean;
  47347. ENVIRONMENTBRDF_RGBD: boolean;
  47348. NORMAL: boolean;
  47349. TANGENT: boolean;
  47350. BUMP: boolean;
  47351. BUMPDIRECTUV: number;
  47352. OBJECTSPACE_NORMALMAP: boolean;
  47353. PARALLAX: boolean;
  47354. PARALLAXOCCLUSION: boolean;
  47355. NORMALXYSCALE: boolean;
  47356. LIGHTMAP: boolean;
  47357. LIGHTMAPDIRECTUV: number;
  47358. USELIGHTMAPASSHADOWMAP: boolean;
  47359. GAMMALIGHTMAP: boolean;
  47360. RGBDLIGHTMAP: boolean;
  47361. REFLECTION: boolean;
  47362. REFLECTIONMAP_3D: boolean;
  47363. REFLECTIONMAP_SPHERICAL: boolean;
  47364. REFLECTIONMAP_PLANAR: boolean;
  47365. REFLECTIONMAP_CUBIC: boolean;
  47366. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47367. REFLECTIONMAP_PROJECTION: boolean;
  47368. REFLECTIONMAP_SKYBOX: boolean;
  47369. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47370. REFLECTIONMAP_EXPLICIT: boolean;
  47371. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47372. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47373. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47374. INVERTCUBICMAP: boolean;
  47375. USESPHERICALFROMREFLECTIONMAP: boolean;
  47376. USEIRRADIANCEMAP: boolean;
  47377. SPHERICAL_HARMONICS: boolean;
  47378. USESPHERICALINVERTEX: boolean;
  47379. REFLECTIONMAP_OPPOSITEZ: boolean;
  47380. LODINREFLECTIONALPHA: boolean;
  47381. GAMMAREFLECTION: boolean;
  47382. RGBDREFLECTION: boolean;
  47383. LINEARSPECULARREFLECTION: boolean;
  47384. RADIANCEOCCLUSION: boolean;
  47385. HORIZONOCCLUSION: boolean;
  47386. INSTANCES: boolean;
  47387. NUM_BONE_INFLUENCERS: number;
  47388. BonesPerMesh: number;
  47389. BONETEXTURE: boolean;
  47390. NONUNIFORMSCALING: boolean;
  47391. MORPHTARGETS: boolean;
  47392. MORPHTARGETS_NORMAL: boolean;
  47393. MORPHTARGETS_TANGENT: boolean;
  47394. MORPHTARGETS_UV: boolean;
  47395. NUM_MORPH_INFLUENCERS: number;
  47396. IMAGEPROCESSING: boolean;
  47397. VIGNETTE: boolean;
  47398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47399. VIGNETTEBLENDMODEOPAQUE: boolean;
  47400. TONEMAPPING: boolean;
  47401. TONEMAPPING_ACES: boolean;
  47402. CONTRAST: boolean;
  47403. COLORCURVES: boolean;
  47404. COLORGRADING: boolean;
  47405. COLORGRADING3D: boolean;
  47406. SAMPLER3DGREENDEPTH: boolean;
  47407. SAMPLER3DBGRMAP: boolean;
  47408. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47409. EXPOSURE: boolean;
  47410. MULTIVIEW: boolean;
  47411. USEPHYSICALLIGHTFALLOFF: boolean;
  47412. USEGLTFLIGHTFALLOFF: boolean;
  47413. TWOSIDEDLIGHTING: boolean;
  47414. SHADOWFLOAT: boolean;
  47415. CLIPPLANE: boolean;
  47416. CLIPPLANE2: boolean;
  47417. CLIPPLANE3: boolean;
  47418. CLIPPLANE4: boolean;
  47419. POINTSIZE: boolean;
  47420. FOG: boolean;
  47421. LOGARITHMICDEPTH: boolean;
  47422. FORCENORMALFORWARD: boolean;
  47423. SPECULARAA: boolean;
  47424. CLEARCOAT: boolean;
  47425. CLEARCOAT_DEFAULTIOR: boolean;
  47426. CLEARCOAT_TEXTURE: boolean;
  47427. CLEARCOAT_TEXTUREDIRECTUV: number;
  47428. CLEARCOAT_BUMP: boolean;
  47429. CLEARCOAT_BUMPDIRECTUV: number;
  47430. CLEARCOAT_TINT: boolean;
  47431. CLEARCOAT_TINT_TEXTURE: boolean;
  47432. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47433. ANISOTROPIC: boolean;
  47434. ANISOTROPIC_TEXTURE: boolean;
  47435. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47436. BRDF_V_HEIGHT_CORRELATED: boolean;
  47437. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47438. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47439. SHEEN: boolean;
  47440. SHEEN_TEXTURE: boolean;
  47441. SHEEN_TEXTUREDIRECTUV: number;
  47442. SHEEN_LINKWITHALBEDO: boolean;
  47443. SUBSURFACE: boolean;
  47444. SS_REFRACTION: boolean;
  47445. SS_TRANSLUCENCY: boolean;
  47446. SS_SCATERRING: boolean;
  47447. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47448. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47449. SS_REFRACTIONMAP_3D: boolean;
  47450. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47451. SS_LODINREFRACTIONALPHA: boolean;
  47452. SS_GAMMAREFRACTION: boolean;
  47453. SS_RGBDREFRACTION: boolean;
  47454. SS_LINEARSPECULARREFRACTION: boolean;
  47455. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47456. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47457. UNLIT: boolean;
  47458. DEBUGMODE: number;
  47459. /**
  47460. * Initializes the PBR Material defines.
  47461. */
  47462. constructor();
  47463. /**
  47464. * Resets the PBR Material defines.
  47465. */
  47466. reset(): void;
  47467. }
  47468. /**
  47469. * The Physically based material base class of BJS.
  47470. *
  47471. * This offers the main features of a standard PBR material.
  47472. * For more information, please refer to the documentation :
  47473. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47474. */
  47475. export abstract class PBRBaseMaterial extends PushMaterial {
  47476. /**
  47477. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47478. */
  47479. static readonly PBRMATERIAL_OPAQUE: number;
  47480. /**
  47481. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47482. */
  47483. static readonly PBRMATERIAL_ALPHATEST: number;
  47484. /**
  47485. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47486. */
  47487. static readonly PBRMATERIAL_ALPHABLEND: number;
  47488. /**
  47489. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47490. * They are also discarded below the alpha cutoff threshold to improve performances.
  47491. */
  47492. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47493. /**
  47494. * Defines the default value of how much AO map is occluding the analytical lights
  47495. * (point spot...).
  47496. */
  47497. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47498. /**
  47499. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47500. */
  47501. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47502. /**
  47503. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47504. * to enhance interoperability with other engines.
  47505. */
  47506. static readonly LIGHTFALLOFF_GLTF: number;
  47507. /**
  47508. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47509. * to enhance interoperability with other materials.
  47510. */
  47511. static readonly LIGHTFALLOFF_STANDARD: number;
  47512. /**
  47513. * Intensity of the direct lights e.g. the four lights available in your scene.
  47514. * This impacts both the direct diffuse and specular highlights.
  47515. */
  47516. protected _directIntensity: number;
  47517. /**
  47518. * Intensity of the emissive part of the material.
  47519. * This helps controlling the emissive effect without modifying the emissive color.
  47520. */
  47521. protected _emissiveIntensity: number;
  47522. /**
  47523. * Intensity of the environment e.g. how much the environment will light the object
  47524. * either through harmonics for rough material or through the refelction for shiny ones.
  47525. */
  47526. protected _environmentIntensity: number;
  47527. /**
  47528. * This is a special control allowing the reduction of the specular highlights coming from the
  47529. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47530. */
  47531. protected _specularIntensity: number;
  47532. /**
  47533. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47534. */
  47535. private _lightingInfos;
  47536. /**
  47537. * Debug Control allowing disabling the bump map on this material.
  47538. */
  47539. protected _disableBumpMap: boolean;
  47540. /**
  47541. * AKA Diffuse Texture in standard nomenclature.
  47542. */
  47543. protected _albedoTexture: Nullable<BaseTexture>;
  47544. /**
  47545. * AKA Occlusion Texture in other nomenclature.
  47546. */
  47547. protected _ambientTexture: Nullable<BaseTexture>;
  47548. /**
  47549. * AKA Occlusion Texture Intensity in other nomenclature.
  47550. */
  47551. protected _ambientTextureStrength: number;
  47552. /**
  47553. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47554. * 1 means it completely occludes it
  47555. * 0 mean it has no impact
  47556. */
  47557. protected _ambientTextureImpactOnAnalyticalLights: number;
  47558. /**
  47559. * Stores the alpha values in a texture.
  47560. */
  47561. protected _opacityTexture: Nullable<BaseTexture>;
  47562. /**
  47563. * Stores the reflection values in a texture.
  47564. */
  47565. protected _reflectionTexture: Nullable<BaseTexture>;
  47566. /**
  47567. * Stores the emissive values in a texture.
  47568. */
  47569. protected _emissiveTexture: Nullable<BaseTexture>;
  47570. /**
  47571. * AKA Specular texture in other nomenclature.
  47572. */
  47573. protected _reflectivityTexture: Nullable<BaseTexture>;
  47574. /**
  47575. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47576. */
  47577. protected _metallicTexture: Nullable<BaseTexture>;
  47578. /**
  47579. * Specifies the metallic scalar of the metallic/roughness workflow.
  47580. * Can also be used to scale the metalness values of the metallic texture.
  47581. */
  47582. protected _metallic: Nullable<number>;
  47583. /**
  47584. * Specifies the roughness scalar of the metallic/roughness workflow.
  47585. * Can also be used to scale the roughness values of the metallic texture.
  47586. */
  47587. protected _roughness: Nullable<number>;
  47588. /**
  47589. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47590. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47591. */
  47592. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47593. /**
  47594. * Stores surface normal data used to displace a mesh in a texture.
  47595. */
  47596. protected _bumpTexture: Nullable<BaseTexture>;
  47597. /**
  47598. * Stores the pre-calculated light information of a mesh in a texture.
  47599. */
  47600. protected _lightmapTexture: Nullable<BaseTexture>;
  47601. /**
  47602. * The color of a material in ambient lighting.
  47603. */
  47604. protected _ambientColor: Color3;
  47605. /**
  47606. * AKA Diffuse Color in other nomenclature.
  47607. */
  47608. protected _albedoColor: Color3;
  47609. /**
  47610. * AKA Specular Color in other nomenclature.
  47611. */
  47612. protected _reflectivityColor: Color3;
  47613. /**
  47614. * The color applied when light is reflected from a material.
  47615. */
  47616. protected _reflectionColor: Color3;
  47617. /**
  47618. * The color applied when light is emitted from a material.
  47619. */
  47620. protected _emissiveColor: Color3;
  47621. /**
  47622. * AKA Glossiness in other nomenclature.
  47623. */
  47624. protected _microSurface: number;
  47625. /**
  47626. * Specifies that the material will use the light map as a show map.
  47627. */
  47628. protected _useLightmapAsShadowmap: boolean;
  47629. /**
  47630. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47631. * makes the reflect vector face the model (under horizon).
  47632. */
  47633. protected _useHorizonOcclusion: boolean;
  47634. /**
  47635. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47636. * too much the area relying on ambient texture to define their ambient occlusion.
  47637. */
  47638. protected _useRadianceOcclusion: boolean;
  47639. /**
  47640. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47641. */
  47642. protected _useAlphaFromAlbedoTexture: boolean;
  47643. /**
  47644. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47645. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47646. */
  47647. protected _useSpecularOverAlpha: boolean;
  47648. /**
  47649. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47650. */
  47651. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47652. /**
  47653. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47654. */
  47655. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47656. /**
  47657. * Specifies if the metallic texture contains the roughness information in its green channel.
  47658. */
  47659. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47660. /**
  47661. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47662. */
  47663. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47664. /**
  47665. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47666. */
  47667. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47668. /**
  47669. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47670. */
  47671. protected _useAmbientInGrayScale: boolean;
  47672. /**
  47673. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47674. * The material will try to infer what glossiness each pixel should be.
  47675. */
  47676. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47677. /**
  47678. * Defines the falloff type used in this material.
  47679. * It by default is Physical.
  47680. */
  47681. protected _lightFalloff: number;
  47682. /**
  47683. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47684. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47685. */
  47686. protected _useRadianceOverAlpha: boolean;
  47687. /**
  47688. * Allows using an object space normal map (instead of tangent space).
  47689. */
  47690. protected _useObjectSpaceNormalMap: boolean;
  47691. /**
  47692. * Allows using the bump map in parallax mode.
  47693. */
  47694. protected _useParallax: boolean;
  47695. /**
  47696. * Allows using the bump map in parallax occlusion mode.
  47697. */
  47698. protected _useParallaxOcclusion: boolean;
  47699. /**
  47700. * Controls the scale bias of the parallax mode.
  47701. */
  47702. protected _parallaxScaleBias: number;
  47703. /**
  47704. * If sets to true, disables all the lights affecting the material.
  47705. */
  47706. protected _disableLighting: boolean;
  47707. /**
  47708. * Number of Simultaneous lights allowed on the material.
  47709. */
  47710. protected _maxSimultaneousLights: number;
  47711. /**
  47712. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47713. */
  47714. protected _invertNormalMapX: boolean;
  47715. /**
  47716. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47717. */
  47718. protected _invertNormalMapY: boolean;
  47719. /**
  47720. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47721. */
  47722. protected _twoSidedLighting: boolean;
  47723. /**
  47724. * Defines the alpha limits in alpha test mode.
  47725. */
  47726. protected _alphaCutOff: number;
  47727. /**
  47728. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47729. */
  47730. protected _forceAlphaTest: boolean;
  47731. /**
  47732. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47733. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47734. */
  47735. protected _useAlphaFresnel: boolean;
  47736. /**
  47737. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47738. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47739. */
  47740. protected _useLinearAlphaFresnel: boolean;
  47741. /**
  47742. * The transparency mode of the material.
  47743. */
  47744. protected _transparencyMode: Nullable<number>;
  47745. /**
  47746. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47747. * from cos thetav and roughness:
  47748. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47749. */
  47750. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47751. /**
  47752. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47753. */
  47754. protected _forceIrradianceInFragment: boolean;
  47755. /**
  47756. * Force normal to face away from face.
  47757. */
  47758. protected _forceNormalForward: boolean;
  47759. /**
  47760. * Enables specular anti aliasing in the PBR shader.
  47761. * It will both interacts on the Geometry for analytical and IBL lighting.
  47762. * It also prefilter the roughness map based on the bump values.
  47763. */
  47764. protected _enableSpecularAntiAliasing: boolean;
  47765. /**
  47766. * Default configuration related to image processing available in the PBR Material.
  47767. */
  47768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47769. /**
  47770. * Keep track of the image processing observer to allow dispose and replace.
  47771. */
  47772. private _imageProcessingObserver;
  47773. /**
  47774. * Attaches a new image processing configuration to the PBR Material.
  47775. * @param configuration
  47776. */
  47777. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47778. /**
  47779. * Stores the available render targets.
  47780. */
  47781. private _renderTargets;
  47782. /**
  47783. * Sets the global ambient color for the material used in lighting calculations.
  47784. */
  47785. private _globalAmbientColor;
  47786. /**
  47787. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47788. */
  47789. private _useLogarithmicDepth;
  47790. /**
  47791. * If set to true, no lighting calculations will be applied.
  47792. */
  47793. private _unlit;
  47794. private _debugMode;
  47795. /**
  47796. * @hidden
  47797. * This is reserved for the inspector.
  47798. * Defines the material debug mode.
  47799. * It helps seeing only some components of the material while troubleshooting.
  47800. */
  47801. debugMode: number;
  47802. /**
  47803. * @hidden
  47804. * This is reserved for the inspector.
  47805. * Specify from where on screen the debug mode should start.
  47806. * The value goes from -1 (full screen) to 1 (not visible)
  47807. * It helps with side by side comparison against the final render
  47808. * This defaults to -1
  47809. */
  47810. private debugLimit;
  47811. /**
  47812. * @hidden
  47813. * This is reserved for the inspector.
  47814. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47815. * You can use the factor to better multiply the final value.
  47816. */
  47817. private debugFactor;
  47818. /**
  47819. * Defines the clear coat layer parameters for the material.
  47820. */
  47821. readonly clearCoat: PBRClearCoatConfiguration;
  47822. /**
  47823. * Defines the anisotropic parameters for the material.
  47824. */
  47825. readonly anisotropy: PBRAnisotropicConfiguration;
  47826. /**
  47827. * Defines the BRDF parameters for the material.
  47828. */
  47829. readonly brdf: PBRBRDFConfiguration;
  47830. /**
  47831. * Defines the Sheen parameters for the material.
  47832. */
  47833. readonly sheen: PBRSheenConfiguration;
  47834. /**
  47835. * Defines the SubSurface parameters for the material.
  47836. */
  47837. readonly subSurface: PBRSubSurfaceConfiguration;
  47838. /**
  47839. * Custom callback helping to override the default shader used in the material.
  47840. */
  47841. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47842. protected _rebuildInParallel: boolean;
  47843. /**
  47844. * Instantiates a new PBRMaterial instance.
  47845. *
  47846. * @param name The material name
  47847. * @param scene The scene the material will be use in.
  47848. */
  47849. constructor(name: string, scene: Scene);
  47850. /**
  47851. * Gets a boolean indicating that current material needs to register RTT
  47852. */
  47853. readonly hasRenderTargetTextures: boolean;
  47854. /**
  47855. * Gets the name of the material class.
  47856. */
  47857. getClassName(): string;
  47858. /**
  47859. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47860. */
  47861. /**
  47862. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47863. */
  47864. useLogarithmicDepth: boolean;
  47865. /**
  47866. * Gets the current transparency mode.
  47867. */
  47868. /**
  47869. * Sets the transparency mode of the material.
  47870. *
  47871. * | Value | Type | Description |
  47872. * | ----- | ----------------------------------- | ----------- |
  47873. * | 0 | OPAQUE | |
  47874. * | 1 | ALPHATEST | |
  47875. * | 2 | ALPHABLEND | |
  47876. * | 3 | ALPHATESTANDBLEND | |
  47877. *
  47878. */
  47879. transparencyMode: Nullable<number>;
  47880. /**
  47881. * Returns true if alpha blending should be disabled.
  47882. */
  47883. private readonly _disableAlphaBlending;
  47884. /**
  47885. * Specifies whether or not this material should be rendered in alpha blend mode.
  47886. */
  47887. needAlphaBlending(): boolean;
  47888. /**
  47889. * Specifies if the mesh will require alpha blending.
  47890. * @param mesh - BJS mesh.
  47891. */
  47892. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47893. /**
  47894. * Specifies whether or not this material should be rendered in alpha test mode.
  47895. */
  47896. needAlphaTesting(): boolean;
  47897. /**
  47898. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47899. */
  47900. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47901. /**
  47902. * Gets the texture used for the alpha test.
  47903. */
  47904. getAlphaTestTexture(): Nullable<BaseTexture>;
  47905. /**
  47906. * Specifies that the submesh is ready to be used.
  47907. * @param mesh - BJS mesh.
  47908. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47909. * @param useInstances - Specifies that instances should be used.
  47910. * @returns - boolean indicating that the submesh is ready or not.
  47911. */
  47912. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47913. /**
  47914. * Specifies if the material uses metallic roughness workflow.
  47915. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47916. */
  47917. isMetallicWorkflow(): boolean;
  47918. private _prepareEffect;
  47919. private _prepareDefines;
  47920. /**
  47921. * Force shader compilation
  47922. */
  47923. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47924. clipPlane: boolean;
  47925. }>): void;
  47926. /**
  47927. * Initializes the uniform buffer layout for the shader.
  47928. */
  47929. buildUniformLayout(): void;
  47930. /**
  47931. * Unbinds the material from the mesh
  47932. */
  47933. unbind(): void;
  47934. /**
  47935. * Binds the submesh data.
  47936. * @param world - The world matrix.
  47937. * @param mesh - The BJS mesh.
  47938. * @param subMesh - A submesh of the BJS mesh.
  47939. */
  47940. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47941. /**
  47942. * Returns the animatable textures.
  47943. * @returns - Array of animatable textures.
  47944. */
  47945. getAnimatables(): IAnimatable[];
  47946. /**
  47947. * Returns the texture used for reflections.
  47948. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47949. */
  47950. private _getReflectionTexture;
  47951. /**
  47952. * Returns an array of the actively used textures.
  47953. * @returns - Array of BaseTextures
  47954. */
  47955. getActiveTextures(): BaseTexture[];
  47956. /**
  47957. * Checks to see if a texture is used in the material.
  47958. * @param texture - Base texture to use.
  47959. * @returns - Boolean specifying if a texture is used in the material.
  47960. */
  47961. hasTexture(texture: BaseTexture): boolean;
  47962. /**
  47963. * Disposes the resources of the material.
  47964. * @param forceDisposeEffect - Forces the disposal of effects.
  47965. * @param forceDisposeTextures - Forces the disposal of all textures.
  47966. */
  47967. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47968. }
  47969. }
  47970. declare module BABYLON {
  47971. /**
  47972. * The Physically based material of BJS.
  47973. *
  47974. * This offers the main features of a standard PBR material.
  47975. * For more information, please refer to the documentation :
  47976. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47977. */
  47978. export class PBRMaterial extends PBRBaseMaterial {
  47979. /**
  47980. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47981. */
  47982. static readonly PBRMATERIAL_OPAQUE: number;
  47983. /**
  47984. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47985. */
  47986. static readonly PBRMATERIAL_ALPHATEST: number;
  47987. /**
  47988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47989. */
  47990. static readonly PBRMATERIAL_ALPHABLEND: number;
  47991. /**
  47992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47993. * They are also discarded below the alpha cutoff threshold to improve performances.
  47994. */
  47995. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47996. /**
  47997. * Defines the default value of how much AO map is occluding the analytical lights
  47998. * (point spot...).
  47999. */
  48000. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48001. /**
  48002. * Intensity of the direct lights e.g. the four lights available in your scene.
  48003. * This impacts both the direct diffuse and specular highlights.
  48004. */
  48005. directIntensity: number;
  48006. /**
  48007. * Intensity of the emissive part of the material.
  48008. * This helps controlling the emissive effect without modifying the emissive color.
  48009. */
  48010. emissiveIntensity: number;
  48011. /**
  48012. * Intensity of the environment e.g. how much the environment will light the object
  48013. * either through harmonics for rough material or through the refelction for shiny ones.
  48014. */
  48015. environmentIntensity: number;
  48016. /**
  48017. * This is a special control allowing the reduction of the specular highlights coming from the
  48018. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48019. */
  48020. specularIntensity: number;
  48021. /**
  48022. * Debug Control allowing disabling the bump map on this material.
  48023. */
  48024. disableBumpMap: boolean;
  48025. /**
  48026. * AKA Diffuse Texture in standard nomenclature.
  48027. */
  48028. albedoTexture: BaseTexture;
  48029. /**
  48030. * AKA Occlusion Texture in other nomenclature.
  48031. */
  48032. ambientTexture: BaseTexture;
  48033. /**
  48034. * AKA Occlusion Texture Intensity in other nomenclature.
  48035. */
  48036. ambientTextureStrength: number;
  48037. /**
  48038. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48039. * 1 means it completely occludes it
  48040. * 0 mean it has no impact
  48041. */
  48042. ambientTextureImpactOnAnalyticalLights: number;
  48043. /**
  48044. * Stores the alpha values in a texture.
  48045. */
  48046. opacityTexture: BaseTexture;
  48047. /**
  48048. * Stores the reflection values in a texture.
  48049. */
  48050. reflectionTexture: Nullable<BaseTexture>;
  48051. /**
  48052. * Stores the emissive values in a texture.
  48053. */
  48054. emissiveTexture: BaseTexture;
  48055. /**
  48056. * AKA Specular texture in other nomenclature.
  48057. */
  48058. reflectivityTexture: BaseTexture;
  48059. /**
  48060. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48061. */
  48062. metallicTexture: BaseTexture;
  48063. /**
  48064. * Specifies the metallic scalar of the metallic/roughness workflow.
  48065. * Can also be used to scale the metalness values of the metallic texture.
  48066. */
  48067. metallic: Nullable<number>;
  48068. /**
  48069. * Specifies the roughness scalar of the metallic/roughness workflow.
  48070. * Can also be used to scale the roughness values of the metallic texture.
  48071. */
  48072. roughness: Nullable<number>;
  48073. /**
  48074. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48075. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48076. */
  48077. microSurfaceTexture: BaseTexture;
  48078. /**
  48079. * Stores surface normal data used to displace a mesh in a texture.
  48080. */
  48081. bumpTexture: BaseTexture;
  48082. /**
  48083. * Stores the pre-calculated light information of a mesh in a texture.
  48084. */
  48085. lightmapTexture: BaseTexture;
  48086. /**
  48087. * Stores the refracted light information in a texture.
  48088. */
  48089. refractionTexture: Nullable<BaseTexture>;
  48090. /**
  48091. * The color of a material in ambient lighting.
  48092. */
  48093. ambientColor: Color3;
  48094. /**
  48095. * AKA Diffuse Color in other nomenclature.
  48096. */
  48097. albedoColor: Color3;
  48098. /**
  48099. * AKA Specular Color in other nomenclature.
  48100. */
  48101. reflectivityColor: Color3;
  48102. /**
  48103. * The color reflected from the material.
  48104. */
  48105. reflectionColor: Color3;
  48106. /**
  48107. * The color emitted from the material.
  48108. */
  48109. emissiveColor: Color3;
  48110. /**
  48111. * AKA Glossiness in other nomenclature.
  48112. */
  48113. microSurface: number;
  48114. /**
  48115. * source material index of refraction (IOR)' / 'destination material IOR.
  48116. */
  48117. indexOfRefraction: number;
  48118. /**
  48119. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48120. */
  48121. invertRefractionY: boolean;
  48122. /**
  48123. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48124. * Materials half opaque for instance using refraction could benefit from this control.
  48125. */
  48126. linkRefractionWithTransparency: boolean;
  48127. /**
  48128. * If true, the light map contains occlusion information instead of lighting info.
  48129. */
  48130. useLightmapAsShadowmap: boolean;
  48131. /**
  48132. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48133. */
  48134. useAlphaFromAlbedoTexture: boolean;
  48135. /**
  48136. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48137. */
  48138. forceAlphaTest: boolean;
  48139. /**
  48140. * Defines the alpha limits in alpha test mode.
  48141. */
  48142. alphaCutOff: number;
  48143. /**
  48144. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48145. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48146. */
  48147. useSpecularOverAlpha: boolean;
  48148. /**
  48149. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48150. */
  48151. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48152. /**
  48153. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48154. */
  48155. useRoughnessFromMetallicTextureAlpha: boolean;
  48156. /**
  48157. * Specifies if the metallic texture contains the roughness information in its green channel.
  48158. */
  48159. useRoughnessFromMetallicTextureGreen: boolean;
  48160. /**
  48161. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48162. */
  48163. useMetallnessFromMetallicTextureBlue: boolean;
  48164. /**
  48165. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48166. */
  48167. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48168. /**
  48169. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48170. */
  48171. useAmbientInGrayScale: boolean;
  48172. /**
  48173. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48174. * The material will try to infer what glossiness each pixel should be.
  48175. */
  48176. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48177. /**
  48178. * BJS is using an harcoded light falloff based on a manually sets up range.
  48179. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48180. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48181. */
  48182. /**
  48183. * BJS is using an harcoded light falloff based on a manually sets up range.
  48184. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48185. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48186. */
  48187. usePhysicalLightFalloff: boolean;
  48188. /**
  48189. * In order to support the falloff compatibility with gltf, a special mode has been added
  48190. * to reproduce the gltf light falloff.
  48191. */
  48192. /**
  48193. * In order to support the falloff compatibility with gltf, a special mode has been added
  48194. * to reproduce the gltf light falloff.
  48195. */
  48196. useGLTFLightFalloff: boolean;
  48197. /**
  48198. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48199. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48200. */
  48201. useRadianceOverAlpha: boolean;
  48202. /**
  48203. * Allows using an object space normal map (instead of tangent space).
  48204. */
  48205. useObjectSpaceNormalMap: boolean;
  48206. /**
  48207. * Allows using the bump map in parallax mode.
  48208. */
  48209. useParallax: boolean;
  48210. /**
  48211. * Allows using the bump map in parallax occlusion mode.
  48212. */
  48213. useParallaxOcclusion: boolean;
  48214. /**
  48215. * Controls the scale bias of the parallax mode.
  48216. */
  48217. parallaxScaleBias: number;
  48218. /**
  48219. * If sets to true, disables all the lights affecting the material.
  48220. */
  48221. disableLighting: boolean;
  48222. /**
  48223. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48224. */
  48225. forceIrradianceInFragment: boolean;
  48226. /**
  48227. * Number of Simultaneous lights allowed on the material.
  48228. */
  48229. maxSimultaneousLights: number;
  48230. /**
  48231. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48232. */
  48233. invertNormalMapX: boolean;
  48234. /**
  48235. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48236. */
  48237. invertNormalMapY: boolean;
  48238. /**
  48239. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48240. */
  48241. twoSidedLighting: boolean;
  48242. /**
  48243. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48244. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48245. */
  48246. useAlphaFresnel: boolean;
  48247. /**
  48248. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48249. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48250. */
  48251. useLinearAlphaFresnel: boolean;
  48252. /**
  48253. * Let user defines the brdf lookup texture used for IBL.
  48254. * A default 8bit version is embedded but you could point at :
  48255. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48256. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48257. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48258. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48259. */
  48260. environmentBRDFTexture: Nullable<BaseTexture>;
  48261. /**
  48262. * Force normal to face away from face.
  48263. */
  48264. forceNormalForward: boolean;
  48265. /**
  48266. * Enables specular anti aliasing in the PBR shader.
  48267. * It will both interacts on the Geometry for analytical and IBL lighting.
  48268. * It also prefilter the roughness map based on the bump values.
  48269. */
  48270. enableSpecularAntiAliasing: boolean;
  48271. /**
  48272. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48273. * makes the reflect vector face the model (under horizon).
  48274. */
  48275. useHorizonOcclusion: boolean;
  48276. /**
  48277. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48278. * too much the area relying on ambient texture to define their ambient occlusion.
  48279. */
  48280. useRadianceOcclusion: boolean;
  48281. /**
  48282. * If set to true, no lighting calculations will be applied.
  48283. */
  48284. unlit: boolean;
  48285. /**
  48286. * Gets the image processing configuration used either in this material.
  48287. */
  48288. /**
  48289. * Sets the Default image processing configuration used either in the this material.
  48290. *
  48291. * If sets to null, the scene one is in use.
  48292. */
  48293. imageProcessingConfiguration: ImageProcessingConfiguration;
  48294. /**
  48295. * Gets wether the color curves effect is enabled.
  48296. */
  48297. /**
  48298. * Sets wether the color curves effect is enabled.
  48299. */
  48300. cameraColorCurvesEnabled: boolean;
  48301. /**
  48302. * Gets wether the color grading effect is enabled.
  48303. */
  48304. /**
  48305. * Gets wether the color grading effect is enabled.
  48306. */
  48307. cameraColorGradingEnabled: boolean;
  48308. /**
  48309. * Gets wether tonemapping is enabled or not.
  48310. */
  48311. /**
  48312. * Sets wether tonemapping is enabled or not
  48313. */
  48314. cameraToneMappingEnabled: boolean;
  48315. /**
  48316. * The camera exposure used on this material.
  48317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48318. * This corresponds to a photographic exposure.
  48319. */
  48320. /**
  48321. * The camera exposure used on this material.
  48322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48323. * This corresponds to a photographic exposure.
  48324. */
  48325. cameraExposure: number;
  48326. /**
  48327. * Gets The camera contrast used on this material.
  48328. */
  48329. /**
  48330. * Sets The camera contrast used on this material.
  48331. */
  48332. cameraContrast: number;
  48333. /**
  48334. * Gets the Color Grading 2D Lookup Texture.
  48335. */
  48336. /**
  48337. * Sets the Color Grading 2D Lookup Texture.
  48338. */
  48339. cameraColorGradingTexture: Nullable<BaseTexture>;
  48340. /**
  48341. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48342. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48343. * 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;
  48344. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48345. */
  48346. /**
  48347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48349. * 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;
  48350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48351. */
  48352. cameraColorCurves: Nullable<ColorCurves>;
  48353. /**
  48354. * Instantiates a new PBRMaterial instance.
  48355. *
  48356. * @param name The material name
  48357. * @param scene The scene the material will be use in.
  48358. */
  48359. constructor(name: string, scene: Scene);
  48360. /**
  48361. * Returns the name of this material class.
  48362. */
  48363. getClassName(): string;
  48364. /**
  48365. * Makes a duplicate of the current material.
  48366. * @param name - name to use for the new material.
  48367. */
  48368. clone(name: string): PBRMaterial;
  48369. /**
  48370. * Serializes this PBR Material.
  48371. * @returns - An object with the serialized material.
  48372. */
  48373. serialize(): any;
  48374. /**
  48375. * Parses a PBR Material from a serialized object.
  48376. * @param source - Serialized object.
  48377. * @param scene - BJS scene instance.
  48378. * @param rootUrl - url for the scene object
  48379. * @returns - PBRMaterial
  48380. */
  48381. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48382. }
  48383. }
  48384. declare module BABYLON {
  48385. /**
  48386. * Direct draw surface info
  48387. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48388. */
  48389. export interface DDSInfo {
  48390. /**
  48391. * Width of the texture
  48392. */
  48393. width: number;
  48394. /**
  48395. * Width of the texture
  48396. */
  48397. height: number;
  48398. /**
  48399. * Number of Mipmaps for the texture
  48400. * @see https://en.wikipedia.org/wiki/Mipmap
  48401. */
  48402. mipmapCount: number;
  48403. /**
  48404. * If the textures format is a known fourCC format
  48405. * @see https://www.fourcc.org/
  48406. */
  48407. isFourCC: boolean;
  48408. /**
  48409. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48410. */
  48411. isRGB: boolean;
  48412. /**
  48413. * If the texture is a lumincance format
  48414. */
  48415. isLuminance: boolean;
  48416. /**
  48417. * If this is a cube texture
  48418. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48419. */
  48420. isCube: boolean;
  48421. /**
  48422. * If the texture is a compressed format eg. FOURCC_DXT1
  48423. */
  48424. isCompressed: boolean;
  48425. /**
  48426. * The dxgiFormat of the texture
  48427. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48428. */
  48429. dxgiFormat: number;
  48430. /**
  48431. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48432. */
  48433. textureType: number;
  48434. /**
  48435. * Sphericle polynomial created for the dds texture
  48436. */
  48437. sphericalPolynomial?: SphericalPolynomial;
  48438. }
  48439. /**
  48440. * Class used to provide DDS decompression tools
  48441. */
  48442. export class DDSTools {
  48443. /**
  48444. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48445. */
  48446. static StoreLODInAlphaChannel: boolean;
  48447. /**
  48448. * Gets DDS information from an array buffer
  48449. * @param arrayBuffer defines the array buffer to read data from
  48450. * @returns the DDS information
  48451. */
  48452. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48453. private static _FloatView;
  48454. private static _Int32View;
  48455. private static _ToHalfFloat;
  48456. private static _FromHalfFloat;
  48457. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48458. private static _GetHalfFloatRGBAArrayBuffer;
  48459. private static _GetFloatRGBAArrayBuffer;
  48460. private static _GetFloatAsUIntRGBAArrayBuffer;
  48461. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48462. private static _GetRGBAArrayBuffer;
  48463. private static _ExtractLongWordOrder;
  48464. private static _GetRGBArrayBuffer;
  48465. private static _GetLuminanceArrayBuffer;
  48466. /**
  48467. * Uploads DDS Levels to a Babylon Texture
  48468. * @hidden
  48469. */
  48470. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48471. }
  48472. interface ThinEngine {
  48473. /**
  48474. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48475. * @param rootUrl defines the url where the file to load is located
  48476. * @param scene defines the current scene
  48477. * @param lodScale defines scale to apply to the mip map selection
  48478. * @param lodOffset defines offset to apply to the mip map selection
  48479. * @param onLoad defines an optional callback raised when the texture is loaded
  48480. * @param onError defines an optional callback raised if there is an issue to load the texture
  48481. * @param format defines the format of the data
  48482. * @param forcedExtension defines the extension to use to pick the right loader
  48483. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48484. * @returns the cube texture as an InternalTexture
  48485. */
  48486. 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;
  48487. }
  48488. }
  48489. declare module BABYLON {
  48490. /**
  48491. * Implementation of the DDS Texture Loader.
  48492. * @hidden
  48493. */
  48494. export class _DDSTextureLoader implements IInternalTextureLoader {
  48495. /**
  48496. * Defines wether the loader supports cascade loading the different faces.
  48497. */
  48498. readonly supportCascades: boolean;
  48499. /**
  48500. * This returns if the loader support the current file information.
  48501. * @param extension defines the file extension of the file being loaded
  48502. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48503. * @param fallback defines the fallback internal texture if any
  48504. * @param isBase64 defines whether the texture is encoded as a base64
  48505. * @param isBuffer defines whether the texture data are stored as a buffer
  48506. * @returns true if the loader can load the specified file
  48507. */
  48508. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48509. /**
  48510. * Transform the url before loading if required.
  48511. * @param rootUrl the url of the texture
  48512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48513. * @returns the transformed texture
  48514. */
  48515. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48516. /**
  48517. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48518. * @param rootUrl the url of the texture
  48519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48520. * @returns the fallback texture
  48521. */
  48522. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48523. /**
  48524. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48525. * @param data contains the texture data
  48526. * @param texture defines the BabylonJS internal texture
  48527. * @param createPolynomials will be true if polynomials have been requested
  48528. * @param onLoad defines the callback to trigger once the texture is ready
  48529. * @param onError defines the callback to trigger in case of error
  48530. */
  48531. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48532. /**
  48533. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48534. * @param data contains the texture data
  48535. * @param texture defines the BabylonJS internal texture
  48536. * @param callback defines the method to call once ready to upload
  48537. */
  48538. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48539. }
  48540. }
  48541. declare module BABYLON {
  48542. /**
  48543. * Implementation of the ENV Texture Loader.
  48544. * @hidden
  48545. */
  48546. export class _ENVTextureLoader implements IInternalTextureLoader {
  48547. /**
  48548. * Defines wether the loader supports cascade loading the different faces.
  48549. */
  48550. readonly supportCascades: boolean;
  48551. /**
  48552. * This returns if the loader support the current file information.
  48553. * @param extension defines the file extension of the file being loaded
  48554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48555. * @param fallback defines the fallback internal texture if any
  48556. * @param isBase64 defines whether the texture is encoded as a base64
  48557. * @param isBuffer defines whether the texture data are stored as a buffer
  48558. * @returns true if the loader can load the specified file
  48559. */
  48560. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48561. /**
  48562. * Transform the url before loading if required.
  48563. * @param rootUrl the url of the texture
  48564. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48565. * @returns the transformed texture
  48566. */
  48567. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48568. /**
  48569. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48570. * @param rootUrl the url of the texture
  48571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48572. * @returns the fallback texture
  48573. */
  48574. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48575. /**
  48576. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48577. * @param data contains the texture data
  48578. * @param texture defines the BabylonJS internal texture
  48579. * @param createPolynomials will be true if polynomials have been requested
  48580. * @param onLoad defines the callback to trigger once the texture is ready
  48581. * @param onError defines the callback to trigger in case of error
  48582. */
  48583. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48584. /**
  48585. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48586. * @param data contains the texture data
  48587. * @param texture defines the BabylonJS internal texture
  48588. * @param callback defines the method to call once ready to upload
  48589. */
  48590. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48591. }
  48592. }
  48593. declare module BABYLON {
  48594. /**
  48595. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48596. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48597. */
  48598. export class KhronosTextureContainer {
  48599. /** contents of the KTX container file */
  48600. arrayBuffer: any;
  48601. private static HEADER_LEN;
  48602. private static COMPRESSED_2D;
  48603. private static COMPRESSED_3D;
  48604. private static TEX_2D;
  48605. private static TEX_3D;
  48606. /**
  48607. * Gets the openGL type
  48608. */
  48609. glType: number;
  48610. /**
  48611. * Gets the openGL type size
  48612. */
  48613. glTypeSize: number;
  48614. /**
  48615. * Gets the openGL format
  48616. */
  48617. glFormat: number;
  48618. /**
  48619. * Gets the openGL internal format
  48620. */
  48621. glInternalFormat: number;
  48622. /**
  48623. * Gets the base internal format
  48624. */
  48625. glBaseInternalFormat: number;
  48626. /**
  48627. * Gets image width in pixel
  48628. */
  48629. pixelWidth: number;
  48630. /**
  48631. * Gets image height in pixel
  48632. */
  48633. pixelHeight: number;
  48634. /**
  48635. * Gets image depth in pixels
  48636. */
  48637. pixelDepth: number;
  48638. /**
  48639. * Gets the number of array elements
  48640. */
  48641. numberOfArrayElements: number;
  48642. /**
  48643. * Gets the number of faces
  48644. */
  48645. numberOfFaces: number;
  48646. /**
  48647. * Gets the number of mipmap levels
  48648. */
  48649. numberOfMipmapLevels: number;
  48650. /**
  48651. * Gets the bytes of key value data
  48652. */
  48653. bytesOfKeyValueData: number;
  48654. /**
  48655. * Gets the load type
  48656. */
  48657. loadType: number;
  48658. /**
  48659. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48660. */
  48661. isInvalid: boolean;
  48662. /**
  48663. * Creates a new KhronosTextureContainer
  48664. * @param arrayBuffer contents of the KTX container file
  48665. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48666. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48667. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48668. */
  48669. constructor(
  48670. /** contents of the KTX container file */
  48671. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48672. /**
  48673. * Uploads KTX content to a Babylon Texture.
  48674. * It is assumed that the texture has already been created & is currently bound
  48675. * @hidden
  48676. */
  48677. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48678. private _upload2DCompressedLevels;
  48679. }
  48680. }
  48681. declare module BABYLON {
  48682. /**
  48683. * Implementation of the KTX Texture Loader.
  48684. * @hidden
  48685. */
  48686. export class _KTXTextureLoader implements IInternalTextureLoader {
  48687. /**
  48688. * Defines wether the loader supports cascade loading the different faces.
  48689. */
  48690. readonly supportCascades: boolean;
  48691. /**
  48692. * This returns if the loader support the current file information.
  48693. * @param extension defines the file extension of the file being loaded
  48694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48695. * @param fallback defines the fallback internal texture if any
  48696. * @param isBase64 defines whether the texture is encoded as a base64
  48697. * @param isBuffer defines whether the texture data are stored as a buffer
  48698. * @returns true if the loader can load the specified file
  48699. */
  48700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48701. /**
  48702. * Transform the url before loading if required.
  48703. * @param rootUrl the url of the texture
  48704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48705. * @returns the transformed texture
  48706. */
  48707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48708. /**
  48709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48710. * @param rootUrl the url of the texture
  48711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48712. * @returns the fallback texture
  48713. */
  48714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48715. /**
  48716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48717. * @param data contains the texture data
  48718. * @param texture defines the BabylonJS internal texture
  48719. * @param createPolynomials will be true if polynomials have been requested
  48720. * @param onLoad defines the callback to trigger once the texture is ready
  48721. * @param onError defines the callback to trigger in case of error
  48722. */
  48723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48724. /**
  48725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48726. * @param data contains the texture data
  48727. * @param texture defines the BabylonJS internal texture
  48728. * @param callback defines the method to call once ready to upload
  48729. */
  48730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48731. }
  48732. }
  48733. declare module BABYLON {
  48734. /**
  48735. * Options for the default xr helper
  48736. */
  48737. export class WebXRDefaultExperienceOptions {
  48738. /**
  48739. * Floor meshes that should be used for teleporting
  48740. */
  48741. floorMeshes: Array<AbstractMesh>;
  48742. }
  48743. /**
  48744. * Default experience which provides a similar setup to the previous webVRExperience
  48745. */
  48746. export class WebXRDefaultExperience {
  48747. /**
  48748. * Base experience
  48749. */
  48750. baseExperience: WebXRExperienceHelper;
  48751. /**
  48752. * Input experience extension
  48753. */
  48754. input: WebXRInput;
  48755. /**
  48756. * Loads the controller models
  48757. */
  48758. controllerModelLoader: WebXRControllerModelLoader;
  48759. /**
  48760. * Enables laser pointer and selection
  48761. */
  48762. pointerSelection: WebXRControllerPointerSelection;
  48763. /**
  48764. * Enables teleportation
  48765. */
  48766. teleportation: WebXRControllerTeleportation;
  48767. /**
  48768. * Enables ui for enetering/exiting xr
  48769. */
  48770. enterExitUI: WebXREnterExitUI;
  48771. /**
  48772. * Default output canvas xr should render to
  48773. */
  48774. outputCanvas: WebXRManagedOutputCanvas;
  48775. /**
  48776. * Creates the default xr experience
  48777. * @param scene scene
  48778. * @param options options for basic configuration
  48779. * @returns resulting WebXRDefaultExperience
  48780. */
  48781. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48782. private constructor();
  48783. /**
  48784. * DIsposes of the experience helper
  48785. */
  48786. dispose(): void;
  48787. }
  48788. }
  48789. declare module BABYLON {
  48790. /** @hidden */
  48791. export var _forceSceneHelpersToBundle: boolean;
  48792. interface Scene {
  48793. /**
  48794. * Creates a default light for the scene.
  48795. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48796. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48797. */
  48798. createDefaultLight(replace?: boolean): void;
  48799. /**
  48800. * Creates a default camera for the scene.
  48801. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48802. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48803. * @param replace has default false, when true replaces the active camera in the scene
  48804. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48805. */
  48806. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48807. /**
  48808. * Creates a default camera and a default light.
  48809. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48810. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48811. * @param replace has the default false, when true replaces the active camera/light in the scene
  48812. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48813. */
  48814. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48815. /**
  48816. * Creates a new sky box
  48817. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48818. * @param environmentTexture defines the texture to use as environment texture
  48819. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48820. * @param scale defines the overall scale of the skybox
  48821. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48822. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48823. * @returns a new mesh holding the sky box
  48824. */
  48825. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48826. /**
  48827. * Creates a new environment
  48828. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48829. * @param options defines the options you can use to configure the environment
  48830. * @returns the new EnvironmentHelper
  48831. */
  48832. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48833. /**
  48834. * Creates a new VREXperienceHelper
  48835. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48836. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48837. * @returns a new VREXperienceHelper
  48838. */
  48839. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48840. /**
  48841. * Creates a new WebXRDefaultExperience
  48842. * @see http://doc.babylonjs.com/how_to/webxr
  48843. * @param options experience options
  48844. * @returns a promise for a new WebXRDefaultExperience
  48845. */
  48846. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48847. }
  48848. }
  48849. declare module BABYLON {
  48850. /**
  48851. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48852. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48853. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48854. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48855. */
  48856. export class VideoDome extends TransformNode {
  48857. /**
  48858. * Define the video source as a Monoscopic panoramic 360 video.
  48859. */
  48860. static readonly MODE_MONOSCOPIC: number;
  48861. /**
  48862. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48863. */
  48864. static readonly MODE_TOPBOTTOM: number;
  48865. /**
  48866. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48867. */
  48868. static readonly MODE_SIDEBYSIDE: number;
  48869. private _halfDome;
  48870. private _useDirectMapping;
  48871. /**
  48872. * The video texture being displayed on the sphere
  48873. */
  48874. protected _videoTexture: VideoTexture;
  48875. /**
  48876. * Gets the video texture being displayed on the sphere
  48877. */
  48878. readonly videoTexture: VideoTexture;
  48879. /**
  48880. * The skybox material
  48881. */
  48882. protected _material: BackgroundMaterial;
  48883. /**
  48884. * The surface used for the skybox
  48885. */
  48886. protected _mesh: Mesh;
  48887. /**
  48888. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48889. */
  48890. private _halfDomeMask;
  48891. /**
  48892. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48893. * Also see the options.resolution property.
  48894. */
  48895. fovMultiplier: number;
  48896. private _videoMode;
  48897. /**
  48898. * Gets or set the current video mode for the video. It can be:
  48899. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48900. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48901. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48902. */
  48903. videoMode: number;
  48904. /**
  48905. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48906. *
  48907. */
  48908. /**
  48909. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48910. */
  48911. halfDome: boolean;
  48912. /**
  48913. * Oberserver used in Stereoscopic VR Mode.
  48914. */
  48915. private _onBeforeCameraRenderObserver;
  48916. /**
  48917. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48918. * @param name Element's name, child elements will append suffixes for their own names.
  48919. * @param urlsOrVideo defines the url(s) or the video element to use
  48920. * @param options An object containing optional or exposed sub element properties
  48921. */
  48922. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48923. resolution?: number;
  48924. clickToPlay?: boolean;
  48925. autoPlay?: boolean;
  48926. loop?: boolean;
  48927. size?: number;
  48928. poster?: string;
  48929. faceForward?: boolean;
  48930. useDirectMapping?: boolean;
  48931. halfDomeMode?: boolean;
  48932. }, scene: Scene);
  48933. private _changeVideoMode;
  48934. /**
  48935. * Releases resources associated with this node.
  48936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48938. */
  48939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48940. }
  48941. }
  48942. declare module BABYLON {
  48943. /**
  48944. * This class can be used to get instrumentation data from a Babylon engine
  48945. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48946. */
  48947. export class EngineInstrumentation implements IDisposable {
  48948. /**
  48949. * Define the instrumented engine.
  48950. */
  48951. engine: Engine;
  48952. private _captureGPUFrameTime;
  48953. private _gpuFrameTimeToken;
  48954. private _gpuFrameTime;
  48955. private _captureShaderCompilationTime;
  48956. private _shaderCompilationTime;
  48957. private _onBeginFrameObserver;
  48958. private _onEndFrameObserver;
  48959. private _onBeforeShaderCompilationObserver;
  48960. private _onAfterShaderCompilationObserver;
  48961. /**
  48962. * Gets the perf counter used for GPU frame time
  48963. */
  48964. readonly gpuFrameTimeCounter: PerfCounter;
  48965. /**
  48966. * Gets the GPU frame time capture status
  48967. */
  48968. /**
  48969. * Enable or disable the GPU frame time capture
  48970. */
  48971. captureGPUFrameTime: boolean;
  48972. /**
  48973. * Gets the perf counter used for shader compilation time
  48974. */
  48975. readonly shaderCompilationTimeCounter: PerfCounter;
  48976. /**
  48977. * Gets the shader compilation time capture status
  48978. */
  48979. /**
  48980. * Enable or disable the shader compilation time capture
  48981. */
  48982. captureShaderCompilationTime: boolean;
  48983. /**
  48984. * Instantiates a new engine instrumentation.
  48985. * This class can be used to get instrumentation data from a Babylon engine
  48986. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48987. * @param engine Defines the engine to instrument
  48988. */
  48989. constructor(
  48990. /**
  48991. * Define the instrumented engine.
  48992. */
  48993. engine: Engine);
  48994. /**
  48995. * Dispose and release associated resources.
  48996. */
  48997. dispose(): void;
  48998. }
  48999. }
  49000. declare module BABYLON {
  49001. /**
  49002. * This class can be used to get instrumentation data from a Babylon engine
  49003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49004. */
  49005. export class SceneInstrumentation implements IDisposable {
  49006. /**
  49007. * Defines the scene to instrument
  49008. */
  49009. scene: Scene;
  49010. private _captureActiveMeshesEvaluationTime;
  49011. private _activeMeshesEvaluationTime;
  49012. private _captureRenderTargetsRenderTime;
  49013. private _renderTargetsRenderTime;
  49014. private _captureFrameTime;
  49015. private _frameTime;
  49016. private _captureRenderTime;
  49017. private _renderTime;
  49018. private _captureInterFrameTime;
  49019. private _interFrameTime;
  49020. private _captureParticlesRenderTime;
  49021. private _particlesRenderTime;
  49022. private _captureSpritesRenderTime;
  49023. private _spritesRenderTime;
  49024. private _capturePhysicsTime;
  49025. private _physicsTime;
  49026. private _captureAnimationsTime;
  49027. private _animationsTime;
  49028. private _captureCameraRenderTime;
  49029. private _cameraRenderTime;
  49030. private _onBeforeActiveMeshesEvaluationObserver;
  49031. private _onAfterActiveMeshesEvaluationObserver;
  49032. private _onBeforeRenderTargetsRenderObserver;
  49033. private _onAfterRenderTargetsRenderObserver;
  49034. private _onAfterRenderObserver;
  49035. private _onBeforeDrawPhaseObserver;
  49036. private _onAfterDrawPhaseObserver;
  49037. private _onBeforeAnimationsObserver;
  49038. private _onBeforeParticlesRenderingObserver;
  49039. private _onAfterParticlesRenderingObserver;
  49040. private _onBeforeSpritesRenderingObserver;
  49041. private _onAfterSpritesRenderingObserver;
  49042. private _onBeforePhysicsObserver;
  49043. private _onAfterPhysicsObserver;
  49044. private _onAfterAnimationsObserver;
  49045. private _onBeforeCameraRenderObserver;
  49046. private _onAfterCameraRenderObserver;
  49047. /**
  49048. * Gets the perf counter used for active meshes evaluation time
  49049. */
  49050. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49051. /**
  49052. * Gets the active meshes evaluation time capture status
  49053. */
  49054. /**
  49055. * Enable or disable the active meshes evaluation time capture
  49056. */
  49057. captureActiveMeshesEvaluationTime: boolean;
  49058. /**
  49059. * Gets the perf counter used for render targets render time
  49060. */
  49061. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49062. /**
  49063. * Gets the render targets render time capture status
  49064. */
  49065. /**
  49066. * Enable or disable the render targets render time capture
  49067. */
  49068. captureRenderTargetsRenderTime: boolean;
  49069. /**
  49070. * Gets the perf counter used for particles render time
  49071. */
  49072. readonly particlesRenderTimeCounter: PerfCounter;
  49073. /**
  49074. * Gets the particles render time capture status
  49075. */
  49076. /**
  49077. * Enable or disable the particles render time capture
  49078. */
  49079. captureParticlesRenderTime: boolean;
  49080. /**
  49081. * Gets the perf counter used for sprites render time
  49082. */
  49083. readonly spritesRenderTimeCounter: PerfCounter;
  49084. /**
  49085. * Gets the sprites render time capture status
  49086. */
  49087. /**
  49088. * Enable or disable the sprites render time capture
  49089. */
  49090. captureSpritesRenderTime: boolean;
  49091. /**
  49092. * Gets the perf counter used for physics time
  49093. */
  49094. readonly physicsTimeCounter: PerfCounter;
  49095. /**
  49096. * Gets the physics time capture status
  49097. */
  49098. /**
  49099. * Enable or disable the physics time capture
  49100. */
  49101. capturePhysicsTime: boolean;
  49102. /**
  49103. * Gets the perf counter used for animations time
  49104. */
  49105. readonly animationsTimeCounter: PerfCounter;
  49106. /**
  49107. * Gets the animations time capture status
  49108. */
  49109. /**
  49110. * Enable or disable the animations time capture
  49111. */
  49112. captureAnimationsTime: boolean;
  49113. /**
  49114. * Gets the perf counter used for frame time capture
  49115. */
  49116. readonly frameTimeCounter: PerfCounter;
  49117. /**
  49118. * Gets the frame time capture status
  49119. */
  49120. /**
  49121. * Enable or disable the frame time capture
  49122. */
  49123. captureFrameTime: boolean;
  49124. /**
  49125. * Gets the perf counter used for inter-frames time capture
  49126. */
  49127. readonly interFrameTimeCounter: PerfCounter;
  49128. /**
  49129. * Gets the inter-frames time capture status
  49130. */
  49131. /**
  49132. * Enable or disable the inter-frames time capture
  49133. */
  49134. captureInterFrameTime: boolean;
  49135. /**
  49136. * Gets the perf counter used for render time capture
  49137. */
  49138. readonly renderTimeCounter: PerfCounter;
  49139. /**
  49140. * Gets the render time capture status
  49141. */
  49142. /**
  49143. * Enable or disable the render time capture
  49144. */
  49145. captureRenderTime: boolean;
  49146. /**
  49147. * Gets the perf counter used for camera render time capture
  49148. */
  49149. readonly cameraRenderTimeCounter: PerfCounter;
  49150. /**
  49151. * Gets the camera render time capture status
  49152. */
  49153. /**
  49154. * Enable or disable the camera render time capture
  49155. */
  49156. captureCameraRenderTime: boolean;
  49157. /**
  49158. * Gets the perf counter used for draw calls
  49159. */
  49160. readonly drawCallsCounter: PerfCounter;
  49161. /**
  49162. * Instantiates a new scene instrumentation.
  49163. * This class can be used to get instrumentation data from a Babylon engine
  49164. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49165. * @param scene Defines the scene to instrument
  49166. */
  49167. constructor(
  49168. /**
  49169. * Defines the scene to instrument
  49170. */
  49171. scene: Scene);
  49172. /**
  49173. * Dispose and release associated resources.
  49174. */
  49175. dispose(): void;
  49176. }
  49177. }
  49178. declare module BABYLON {
  49179. /** @hidden */
  49180. export var glowMapGenerationPixelShader: {
  49181. name: string;
  49182. shader: string;
  49183. };
  49184. }
  49185. declare module BABYLON {
  49186. /** @hidden */
  49187. export var glowMapGenerationVertexShader: {
  49188. name: string;
  49189. shader: string;
  49190. };
  49191. }
  49192. declare module BABYLON {
  49193. /**
  49194. * Effect layer options. This helps customizing the behaviour
  49195. * of the effect layer.
  49196. */
  49197. export interface IEffectLayerOptions {
  49198. /**
  49199. * Multiplication factor apply to the canvas size to compute the render target size
  49200. * used to generated the objects (the smaller the faster).
  49201. */
  49202. mainTextureRatio: number;
  49203. /**
  49204. * Enforces a fixed size texture to ensure effect stability across devices.
  49205. */
  49206. mainTextureFixedSize?: number;
  49207. /**
  49208. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49209. */
  49210. alphaBlendingMode: number;
  49211. /**
  49212. * The camera attached to the layer.
  49213. */
  49214. camera: Nullable<Camera>;
  49215. /**
  49216. * The rendering group to draw the layer in.
  49217. */
  49218. renderingGroupId: number;
  49219. }
  49220. /**
  49221. * The effect layer Helps adding post process effect blended with the main pass.
  49222. *
  49223. * This can be for instance use to generate glow or higlight effects on the scene.
  49224. *
  49225. * The effect layer class can not be used directly and is intented to inherited from to be
  49226. * customized per effects.
  49227. */
  49228. export abstract class EffectLayer {
  49229. private _vertexBuffers;
  49230. private _indexBuffer;
  49231. private _cachedDefines;
  49232. private _effectLayerMapGenerationEffect;
  49233. private _effectLayerOptions;
  49234. private _mergeEffect;
  49235. protected _scene: Scene;
  49236. protected _engine: Engine;
  49237. protected _maxSize: number;
  49238. protected _mainTextureDesiredSize: ISize;
  49239. protected _mainTexture: RenderTargetTexture;
  49240. protected _shouldRender: boolean;
  49241. protected _postProcesses: PostProcess[];
  49242. protected _textures: BaseTexture[];
  49243. protected _emissiveTextureAndColor: {
  49244. texture: Nullable<BaseTexture>;
  49245. color: Color4;
  49246. };
  49247. /**
  49248. * The name of the layer
  49249. */
  49250. name: string;
  49251. /**
  49252. * The clear color of the texture used to generate the glow map.
  49253. */
  49254. neutralColor: Color4;
  49255. /**
  49256. * Specifies wether the highlight layer is enabled or not.
  49257. */
  49258. isEnabled: boolean;
  49259. /**
  49260. * Gets the camera attached to the layer.
  49261. */
  49262. readonly camera: Nullable<Camera>;
  49263. /**
  49264. * Gets the rendering group id the layer should render in.
  49265. */
  49266. renderingGroupId: number;
  49267. /**
  49268. * An event triggered when the effect layer has been disposed.
  49269. */
  49270. onDisposeObservable: Observable<EffectLayer>;
  49271. /**
  49272. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49273. */
  49274. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49275. /**
  49276. * An event triggered when the generated texture is being merged in the scene.
  49277. */
  49278. onBeforeComposeObservable: Observable<EffectLayer>;
  49279. /**
  49280. * An event triggered when the generated texture has been merged in the scene.
  49281. */
  49282. onAfterComposeObservable: Observable<EffectLayer>;
  49283. /**
  49284. * An event triggered when the efffect layer changes its size.
  49285. */
  49286. onSizeChangedObservable: Observable<EffectLayer>;
  49287. /** @hidden */
  49288. static _SceneComponentInitialization: (scene: Scene) => void;
  49289. /**
  49290. * Instantiates a new effect Layer and references it in the scene.
  49291. * @param name The name of the layer
  49292. * @param scene The scene to use the layer in
  49293. */
  49294. constructor(
  49295. /** The Friendly of the effect in the scene */
  49296. name: string, scene: Scene);
  49297. /**
  49298. * Get the effect name of the layer.
  49299. * @return The effect name
  49300. */
  49301. abstract getEffectName(): string;
  49302. /**
  49303. * Checks for the readiness of the element composing the layer.
  49304. * @param subMesh the mesh to check for
  49305. * @param useInstances specify wether or not to use instances to render the mesh
  49306. * @return true if ready otherwise, false
  49307. */
  49308. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49309. /**
  49310. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49311. * @returns true if the effect requires stencil during the main canvas render pass.
  49312. */
  49313. abstract needStencil(): boolean;
  49314. /**
  49315. * Create the merge effect. This is the shader use to blit the information back
  49316. * to the main canvas at the end of the scene rendering.
  49317. * @returns The effect containing the shader used to merge the effect on the main canvas
  49318. */
  49319. protected abstract _createMergeEffect(): Effect;
  49320. /**
  49321. * Creates the render target textures and post processes used in the effect layer.
  49322. */
  49323. protected abstract _createTextureAndPostProcesses(): void;
  49324. /**
  49325. * Implementation specific of rendering the generating effect on the main canvas.
  49326. * @param effect The effect used to render through
  49327. */
  49328. protected abstract _internalRender(effect: Effect): void;
  49329. /**
  49330. * Sets the required values for both the emissive texture and and the main color.
  49331. */
  49332. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49333. /**
  49334. * Free any resources and references associated to a mesh.
  49335. * Internal use
  49336. * @param mesh The mesh to free.
  49337. */
  49338. abstract _disposeMesh(mesh: Mesh): void;
  49339. /**
  49340. * Serializes this layer (Glow or Highlight for example)
  49341. * @returns a serialized layer object
  49342. */
  49343. abstract serialize?(): any;
  49344. /**
  49345. * Initializes the effect layer with the required options.
  49346. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49347. */
  49348. protected _init(options: Partial<IEffectLayerOptions>): void;
  49349. /**
  49350. * Generates the index buffer of the full screen quad blending to the main canvas.
  49351. */
  49352. private _generateIndexBuffer;
  49353. /**
  49354. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49355. */
  49356. private _generateVertexBuffer;
  49357. /**
  49358. * Sets the main texture desired size which is the closest power of two
  49359. * of the engine canvas size.
  49360. */
  49361. private _setMainTextureSize;
  49362. /**
  49363. * Creates the main texture for the effect layer.
  49364. */
  49365. protected _createMainTexture(): void;
  49366. /**
  49367. * Adds specific effects defines.
  49368. * @param defines The defines to add specifics to.
  49369. */
  49370. protected _addCustomEffectDefines(defines: string[]): void;
  49371. /**
  49372. * Checks for the readiness of the element composing the layer.
  49373. * @param subMesh the mesh to check for
  49374. * @param useInstances specify wether or not to use instances to render the mesh
  49375. * @param emissiveTexture the associated emissive texture used to generate the glow
  49376. * @return true if ready otherwise, false
  49377. */
  49378. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49379. /**
  49380. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49381. */
  49382. render(): void;
  49383. /**
  49384. * Determine if a given mesh will be used in the current effect.
  49385. * @param mesh mesh to test
  49386. * @returns true if the mesh will be used
  49387. */
  49388. hasMesh(mesh: AbstractMesh): boolean;
  49389. /**
  49390. * Returns true if the layer contains information to display, otherwise false.
  49391. * @returns true if the glow layer should be rendered
  49392. */
  49393. shouldRender(): boolean;
  49394. /**
  49395. * Returns true if the mesh should render, otherwise false.
  49396. * @param mesh The mesh to render
  49397. * @returns true if it should render otherwise false
  49398. */
  49399. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49400. /**
  49401. * Returns true if the mesh can be rendered, otherwise false.
  49402. * @param mesh The mesh to render
  49403. * @param material The material used on the mesh
  49404. * @returns true if it can be rendered otherwise false
  49405. */
  49406. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49407. /**
  49408. * Returns true if the mesh should render, otherwise false.
  49409. * @param mesh The mesh to render
  49410. * @returns true if it should render otherwise false
  49411. */
  49412. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49413. /**
  49414. * Renders the submesh passed in parameter to the generation map.
  49415. */
  49416. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49417. /**
  49418. * Rebuild the required buffers.
  49419. * @hidden Internal use only.
  49420. */
  49421. _rebuild(): void;
  49422. /**
  49423. * Dispose only the render target textures and post process.
  49424. */
  49425. private _disposeTextureAndPostProcesses;
  49426. /**
  49427. * Dispose the highlight layer and free resources.
  49428. */
  49429. dispose(): void;
  49430. /**
  49431. * Gets the class name of the effect layer
  49432. * @returns the string with the class name of the effect layer
  49433. */
  49434. getClassName(): string;
  49435. /**
  49436. * Creates an effect layer from parsed effect layer data
  49437. * @param parsedEffectLayer defines effect layer data
  49438. * @param scene defines the current scene
  49439. * @param rootUrl defines the root URL containing the effect layer information
  49440. * @returns a parsed effect Layer
  49441. */
  49442. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49443. }
  49444. }
  49445. declare module BABYLON {
  49446. interface AbstractScene {
  49447. /**
  49448. * The list of effect layers (highlights/glow) added to the scene
  49449. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49450. * @see http://doc.babylonjs.com/how_to/glow_layer
  49451. */
  49452. effectLayers: Array<EffectLayer>;
  49453. /**
  49454. * Removes the given effect layer from this scene.
  49455. * @param toRemove defines the effect layer to remove
  49456. * @returns the index of the removed effect layer
  49457. */
  49458. removeEffectLayer(toRemove: EffectLayer): number;
  49459. /**
  49460. * Adds the given effect layer to this scene
  49461. * @param newEffectLayer defines the effect layer to add
  49462. */
  49463. addEffectLayer(newEffectLayer: EffectLayer): void;
  49464. }
  49465. /**
  49466. * Defines the layer scene component responsible to manage any effect layers
  49467. * in a given scene.
  49468. */
  49469. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49470. /**
  49471. * The component name helpfull to identify the component in the list of scene components.
  49472. */
  49473. readonly name: string;
  49474. /**
  49475. * The scene the component belongs to.
  49476. */
  49477. scene: Scene;
  49478. private _engine;
  49479. private _renderEffects;
  49480. private _needStencil;
  49481. private _previousStencilState;
  49482. /**
  49483. * Creates a new instance of the component for the given scene
  49484. * @param scene Defines the scene to register the component in
  49485. */
  49486. constructor(scene: Scene);
  49487. /**
  49488. * Registers the component in a given scene
  49489. */
  49490. register(): void;
  49491. /**
  49492. * Rebuilds the elements related to this component in case of
  49493. * context lost for instance.
  49494. */
  49495. rebuild(): void;
  49496. /**
  49497. * Serializes the component data to the specified json object
  49498. * @param serializationObject The object to serialize to
  49499. */
  49500. serialize(serializationObject: any): void;
  49501. /**
  49502. * Adds all the elements from the container to the scene
  49503. * @param container the container holding the elements
  49504. */
  49505. addFromContainer(container: AbstractScene): void;
  49506. /**
  49507. * Removes all the elements in the container from the scene
  49508. * @param container contains the elements to remove
  49509. * @param dispose if the removed element should be disposed (default: false)
  49510. */
  49511. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49512. /**
  49513. * Disposes the component and the associated ressources.
  49514. */
  49515. dispose(): void;
  49516. private _isReadyForMesh;
  49517. private _renderMainTexture;
  49518. private _setStencil;
  49519. private _setStencilBack;
  49520. private _draw;
  49521. private _drawCamera;
  49522. private _drawRenderingGroup;
  49523. }
  49524. }
  49525. declare module BABYLON {
  49526. /** @hidden */
  49527. export var glowMapMergePixelShader: {
  49528. name: string;
  49529. shader: string;
  49530. };
  49531. }
  49532. declare module BABYLON {
  49533. /** @hidden */
  49534. export var glowMapMergeVertexShader: {
  49535. name: string;
  49536. shader: string;
  49537. };
  49538. }
  49539. declare module BABYLON {
  49540. interface AbstractScene {
  49541. /**
  49542. * Return a the first highlight layer of the scene with a given name.
  49543. * @param name The name of the highlight layer to look for.
  49544. * @return The highlight layer if found otherwise null.
  49545. */
  49546. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49547. }
  49548. /**
  49549. * Glow layer options. This helps customizing the behaviour
  49550. * of the glow layer.
  49551. */
  49552. export interface IGlowLayerOptions {
  49553. /**
  49554. * Multiplication factor apply to the canvas size to compute the render target size
  49555. * used to generated the glowing objects (the smaller the faster).
  49556. */
  49557. mainTextureRatio: number;
  49558. /**
  49559. * Enforces a fixed size texture to ensure resize independant blur.
  49560. */
  49561. mainTextureFixedSize?: number;
  49562. /**
  49563. * How big is the kernel of the blur texture.
  49564. */
  49565. blurKernelSize: number;
  49566. /**
  49567. * The camera attached to the layer.
  49568. */
  49569. camera: Nullable<Camera>;
  49570. /**
  49571. * Enable MSAA by chosing the number of samples.
  49572. */
  49573. mainTextureSamples?: number;
  49574. /**
  49575. * The rendering group to draw the layer in.
  49576. */
  49577. renderingGroupId: number;
  49578. }
  49579. /**
  49580. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49581. *
  49582. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49583. * glowy meshes to your scene.
  49584. *
  49585. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49586. */
  49587. export class GlowLayer extends EffectLayer {
  49588. /**
  49589. * Effect Name of the layer.
  49590. */
  49591. static readonly EffectName: string;
  49592. /**
  49593. * The default blur kernel size used for the glow.
  49594. */
  49595. static DefaultBlurKernelSize: number;
  49596. /**
  49597. * The default texture size ratio used for the glow.
  49598. */
  49599. static DefaultTextureRatio: number;
  49600. /**
  49601. * Sets the kernel size of the blur.
  49602. */
  49603. /**
  49604. * Gets the kernel size of the blur.
  49605. */
  49606. blurKernelSize: number;
  49607. /**
  49608. * Sets the glow intensity.
  49609. */
  49610. /**
  49611. * Gets the glow intensity.
  49612. */
  49613. intensity: number;
  49614. private _options;
  49615. private _intensity;
  49616. private _horizontalBlurPostprocess1;
  49617. private _verticalBlurPostprocess1;
  49618. private _horizontalBlurPostprocess2;
  49619. private _verticalBlurPostprocess2;
  49620. private _blurTexture1;
  49621. private _blurTexture2;
  49622. private _postProcesses1;
  49623. private _postProcesses2;
  49624. private _includedOnlyMeshes;
  49625. private _excludedMeshes;
  49626. /**
  49627. * Callback used to let the user override the color selection on a per mesh basis
  49628. */
  49629. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49630. /**
  49631. * Callback used to let the user override the texture selection on a per mesh basis
  49632. */
  49633. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49634. /**
  49635. * Instantiates a new glow Layer and references it to the scene.
  49636. * @param name The name of the layer
  49637. * @param scene The scene to use the layer in
  49638. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49639. */
  49640. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49641. /**
  49642. * Get the effect name of the layer.
  49643. * @return The effect name
  49644. */
  49645. getEffectName(): string;
  49646. /**
  49647. * Create the merge effect. This is the shader use to blit the information back
  49648. * to the main canvas at the end of the scene rendering.
  49649. */
  49650. protected _createMergeEffect(): Effect;
  49651. /**
  49652. * Creates the render target textures and post processes used in the glow layer.
  49653. */
  49654. protected _createTextureAndPostProcesses(): void;
  49655. /**
  49656. * Checks for the readiness of the element composing the layer.
  49657. * @param subMesh the mesh to check for
  49658. * @param useInstances specify wether or not to use instances to render the mesh
  49659. * @param emissiveTexture the associated emissive texture used to generate the glow
  49660. * @return true if ready otherwise, false
  49661. */
  49662. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49663. /**
  49664. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49665. */
  49666. needStencil(): boolean;
  49667. /**
  49668. * Returns true if the mesh can be rendered, otherwise false.
  49669. * @param mesh The mesh to render
  49670. * @param material The material used on the mesh
  49671. * @returns true if it can be rendered otherwise false
  49672. */
  49673. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49674. /**
  49675. * Implementation specific of rendering the generating effect on the main canvas.
  49676. * @param effect The effect used to render through
  49677. */
  49678. protected _internalRender(effect: Effect): void;
  49679. /**
  49680. * Sets the required values for both the emissive texture and and the main color.
  49681. */
  49682. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49683. /**
  49684. * Returns true if the mesh should render, otherwise false.
  49685. * @param mesh The mesh to render
  49686. * @returns true if it should render otherwise false
  49687. */
  49688. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49689. /**
  49690. * Adds specific effects defines.
  49691. * @param defines The defines to add specifics to.
  49692. */
  49693. protected _addCustomEffectDefines(defines: string[]): void;
  49694. /**
  49695. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49696. * @param mesh The mesh to exclude from the glow layer
  49697. */
  49698. addExcludedMesh(mesh: Mesh): void;
  49699. /**
  49700. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49701. * @param mesh The mesh to remove
  49702. */
  49703. removeExcludedMesh(mesh: Mesh): void;
  49704. /**
  49705. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49706. * @param mesh The mesh to include in the glow layer
  49707. */
  49708. addIncludedOnlyMesh(mesh: Mesh): void;
  49709. /**
  49710. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49711. * @param mesh The mesh to remove
  49712. */
  49713. removeIncludedOnlyMesh(mesh: Mesh): void;
  49714. /**
  49715. * Determine if a given mesh will be used in the glow layer
  49716. * @param mesh The mesh to test
  49717. * @returns true if the mesh will be highlighted by the current glow layer
  49718. */
  49719. hasMesh(mesh: AbstractMesh): boolean;
  49720. /**
  49721. * Free any resources and references associated to a mesh.
  49722. * Internal use
  49723. * @param mesh The mesh to free.
  49724. * @hidden
  49725. */
  49726. _disposeMesh(mesh: Mesh): void;
  49727. /**
  49728. * Gets the class name of the effect layer
  49729. * @returns the string with the class name of the effect layer
  49730. */
  49731. getClassName(): string;
  49732. /**
  49733. * Serializes this glow layer
  49734. * @returns a serialized glow layer object
  49735. */
  49736. serialize(): any;
  49737. /**
  49738. * Creates a Glow Layer from parsed glow layer data
  49739. * @param parsedGlowLayer defines glow layer data
  49740. * @param scene defines the current scene
  49741. * @param rootUrl defines the root URL containing the glow layer information
  49742. * @returns a parsed Glow Layer
  49743. */
  49744. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49745. }
  49746. }
  49747. declare module BABYLON {
  49748. /** @hidden */
  49749. export var glowBlurPostProcessPixelShader: {
  49750. name: string;
  49751. shader: string;
  49752. };
  49753. }
  49754. declare module BABYLON {
  49755. interface AbstractScene {
  49756. /**
  49757. * Return a the first highlight layer of the scene with a given name.
  49758. * @param name The name of the highlight layer to look for.
  49759. * @return The highlight layer if found otherwise null.
  49760. */
  49761. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49762. }
  49763. /**
  49764. * Highlight layer options. This helps customizing the behaviour
  49765. * of the highlight layer.
  49766. */
  49767. export interface IHighlightLayerOptions {
  49768. /**
  49769. * Multiplication factor apply to the canvas size to compute the render target size
  49770. * used to generated the glowing objects (the smaller the faster).
  49771. */
  49772. mainTextureRatio: number;
  49773. /**
  49774. * Enforces a fixed size texture to ensure resize independant blur.
  49775. */
  49776. mainTextureFixedSize?: number;
  49777. /**
  49778. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49779. * of the picture to blur (the smaller the faster).
  49780. */
  49781. blurTextureSizeRatio: number;
  49782. /**
  49783. * How big in texel of the blur texture is the vertical blur.
  49784. */
  49785. blurVerticalSize: number;
  49786. /**
  49787. * How big in texel of the blur texture is the horizontal blur.
  49788. */
  49789. blurHorizontalSize: number;
  49790. /**
  49791. * Alpha blending mode used to apply the blur. Default is combine.
  49792. */
  49793. alphaBlendingMode: number;
  49794. /**
  49795. * The camera attached to the layer.
  49796. */
  49797. camera: Nullable<Camera>;
  49798. /**
  49799. * Should we display highlight as a solid stroke?
  49800. */
  49801. isStroke?: boolean;
  49802. /**
  49803. * The rendering group to draw the layer in.
  49804. */
  49805. renderingGroupId: number;
  49806. }
  49807. /**
  49808. * The highlight layer Helps adding a glow effect around a mesh.
  49809. *
  49810. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49811. * glowy meshes to your scene.
  49812. *
  49813. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49814. */
  49815. export class HighlightLayer extends EffectLayer {
  49816. name: string;
  49817. /**
  49818. * Effect Name of the highlight layer.
  49819. */
  49820. static readonly EffectName: string;
  49821. /**
  49822. * The neutral color used during the preparation of the glow effect.
  49823. * This is black by default as the blend operation is a blend operation.
  49824. */
  49825. static NeutralColor: Color4;
  49826. /**
  49827. * Stencil value used for glowing meshes.
  49828. */
  49829. static GlowingMeshStencilReference: number;
  49830. /**
  49831. * Stencil value used for the other meshes in the scene.
  49832. */
  49833. static NormalMeshStencilReference: number;
  49834. /**
  49835. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49836. */
  49837. innerGlow: boolean;
  49838. /**
  49839. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49840. */
  49841. outerGlow: boolean;
  49842. /**
  49843. * Specifies the horizontal size of the blur.
  49844. */
  49845. /**
  49846. * Gets the horizontal size of the blur.
  49847. */
  49848. blurHorizontalSize: number;
  49849. /**
  49850. * Specifies the vertical size of the blur.
  49851. */
  49852. /**
  49853. * Gets the vertical size of the blur.
  49854. */
  49855. blurVerticalSize: number;
  49856. /**
  49857. * An event triggered when the highlight layer is being blurred.
  49858. */
  49859. onBeforeBlurObservable: Observable<HighlightLayer>;
  49860. /**
  49861. * An event triggered when the highlight layer has been blurred.
  49862. */
  49863. onAfterBlurObservable: Observable<HighlightLayer>;
  49864. private _instanceGlowingMeshStencilReference;
  49865. private _options;
  49866. private _downSamplePostprocess;
  49867. private _horizontalBlurPostprocess;
  49868. private _verticalBlurPostprocess;
  49869. private _blurTexture;
  49870. private _meshes;
  49871. private _excludedMeshes;
  49872. /**
  49873. * Instantiates a new highlight Layer and references it to the scene..
  49874. * @param name The name of the layer
  49875. * @param scene The scene to use the layer in
  49876. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49877. */
  49878. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49879. /**
  49880. * Get the effect name of the layer.
  49881. * @return The effect name
  49882. */
  49883. getEffectName(): string;
  49884. /**
  49885. * Create the merge effect. This is the shader use to blit the information back
  49886. * to the main canvas at the end of the scene rendering.
  49887. */
  49888. protected _createMergeEffect(): Effect;
  49889. /**
  49890. * Creates the render target textures and post processes used in the highlight layer.
  49891. */
  49892. protected _createTextureAndPostProcesses(): void;
  49893. /**
  49894. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49895. */
  49896. needStencil(): boolean;
  49897. /**
  49898. * Checks for the readiness of the element composing the layer.
  49899. * @param subMesh the mesh to check for
  49900. * @param useInstances specify wether or not to use instances to render the mesh
  49901. * @param emissiveTexture the associated emissive texture used to generate the glow
  49902. * @return true if ready otherwise, false
  49903. */
  49904. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49905. /**
  49906. * Implementation specific of rendering the generating effect on the main canvas.
  49907. * @param effect The effect used to render through
  49908. */
  49909. protected _internalRender(effect: Effect): void;
  49910. /**
  49911. * Returns true if the layer contains information to display, otherwise false.
  49912. */
  49913. shouldRender(): boolean;
  49914. /**
  49915. * Returns true if the mesh should render, otherwise false.
  49916. * @param mesh The mesh to render
  49917. * @returns true if it should render otherwise false
  49918. */
  49919. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49920. /**
  49921. * Sets the required values for both the emissive texture and and the main color.
  49922. */
  49923. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49924. /**
  49925. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49926. * @param mesh The mesh to exclude from the highlight layer
  49927. */
  49928. addExcludedMesh(mesh: Mesh): void;
  49929. /**
  49930. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49931. * @param mesh The mesh to highlight
  49932. */
  49933. removeExcludedMesh(mesh: Mesh): void;
  49934. /**
  49935. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49936. * @param mesh mesh to test
  49937. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49938. */
  49939. hasMesh(mesh: AbstractMesh): boolean;
  49940. /**
  49941. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49942. * @param mesh The mesh to highlight
  49943. * @param color The color of the highlight
  49944. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49945. */
  49946. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49947. /**
  49948. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49949. * @param mesh The mesh to highlight
  49950. */
  49951. removeMesh(mesh: Mesh): void;
  49952. /**
  49953. * Force the stencil to the normal expected value for none glowing parts
  49954. */
  49955. private _defaultStencilReference;
  49956. /**
  49957. * Free any resources and references associated to a mesh.
  49958. * Internal use
  49959. * @param mesh The mesh to free.
  49960. * @hidden
  49961. */
  49962. _disposeMesh(mesh: Mesh): void;
  49963. /**
  49964. * Dispose the highlight layer and free resources.
  49965. */
  49966. dispose(): void;
  49967. /**
  49968. * Gets the class name of the effect layer
  49969. * @returns the string with the class name of the effect layer
  49970. */
  49971. getClassName(): string;
  49972. /**
  49973. * Serializes this Highlight layer
  49974. * @returns a serialized Highlight layer object
  49975. */
  49976. serialize(): any;
  49977. /**
  49978. * Creates a Highlight layer from parsed Highlight layer data
  49979. * @param parsedHightlightLayer defines the Highlight layer data
  49980. * @param scene defines the current scene
  49981. * @param rootUrl defines the root URL containing the Highlight layer information
  49982. * @returns a parsed Highlight layer
  49983. */
  49984. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49985. }
  49986. }
  49987. declare module BABYLON {
  49988. interface AbstractScene {
  49989. /**
  49990. * The list of layers (background and foreground) of the scene
  49991. */
  49992. layers: Array<Layer>;
  49993. }
  49994. /**
  49995. * Defines the layer scene component responsible to manage any layers
  49996. * in a given scene.
  49997. */
  49998. export class LayerSceneComponent implements ISceneComponent {
  49999. /**
  50000. * The component name helpfull to identify the component in the list of scene components.
  50001. */
  50002. readonly name: string;
  50003. /**
  50004. * The scene the component belongs to.
  50005. */
  50006. scene: Scene;
  50007. private _engine;
  50008. /**
  50009. * Creates a new instance of the component for the given scene
  50010. * @param scene Defines the scene to register the component in
  50011. */
  50012. constructor(scene: Scene);
  50013. /**
  50014. * Registers the component in a given scene
  50015. */
  50016. register(): void;
  50017. /**
  50018. * Rebuilds the elements related to this component in case of
  50019. * context lost for instance.
  50020. */
  50021. rebuild(): void;
  50022. /**
  50023. * Disposes the component and the associated ressources.
  50024. */
  50025. dispose(): void;
  50026. private _draw;
  50027. private _drawCameraPredicate;
  50028. private _drawCameraBackground;
  50029. private _drawCameraForeground;
  50030. private _drawRenderTargetPredicate;
  50031. private _drawRenderTargetBackground;
  50032. private _drawRenderTargetForeground;
  50033. /**
  50034. * Adds all the elements from the container to the scene
  50035. * @param container the container holding the elements
  50036. */
  50037. addFromContainer(container: AbstractScene): void;
  50038. /**
  50039. * Removes all the elements in the container from the scene
  50040. * @param container contains the elements to remove
  50041. * @param dispose if the removed element should be disposed (default: false)
  50042. */
  50043. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50044. }
  50045. }
  50046. declare module BABYLON {
  50047. /** @hidden */
  50048. export var layerPixelShader: {
  50049. name: string;
  50050. shader: string;
  50051. };
  50052. }
  50053. declare module BABYLON {
  50054. /** @hidden */
  50055. export var layerVertexShader: {
  50056. name: string;
  50057. shader: string;
  50058. };
  50059. }
  50060. declare module BABYLON {
  50061. /**
  50062. * This represents a full screen 2d layer.
  50063. * This can be useful to display a picture in the background of your scene for instance.
  50064. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50065. */
  50066. export class Layer {
  50067. /**
  50068. * Define the name of the layer.
  50069. */
  50070. name: string;
  50071. /**
  50072. * Define the texture the layer should display.
  50073. */
  50074. texture: Nullable<Texture>;
  50075. /**
  50076. * Is the layer in background or foreground.
  50077. */
  50078. isBackground: boolean;
  50079. /**
  50080. * Define the color of the layer (instead of texture).
  50081. */
  50082. color: Color4;
  50083. /**
  50084. * Define the scale of the layer in order to zoom in out of the texture.
  50085. */
  50086. scale: Vector2;
  50087. /**
  50088. * Define an offset for the layer in order to shift the texture.
  50089. */
  50090. offset: Vector2;
  50091. /**
  50092. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50093. */
  50094. alphaBlendingMode: number;
  50095. /**
  50096. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50097. * Alpha test will not mix with the background color in case of transparency.
  50098. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50099. */
  50100. alphaTest: boolean;
  50101. /**
  50102. * Define a mask to restrict the layer to only some of the scene cameras.
  50103. */
  50104. layerMask: number;
  50105. /**
  50106. * Define the list of render target the layer is visible into.
  50107. */
  50108. renderTargetTextures: RenderTargetTexture[];
  50109. /**
  50110. * Define if the layer is only used in renderTarget or if it also
  50111. * renders in the main frame buffer of the canvas.
  50112. */
  50113. renderOnlyInRenderTargetTextures: boolean;
  50114. private _scene;
  50115. private _vertexBuffers;
  50116. private _indexBuffer;
  50117. private _effect;
  50118. private _alphaTestEffect;
  50119. /**
  50120. * An event triggered when the layer is disposed.
  50121. */
  50122. onDisposeObservable: Observable<Layer>;
  50123. private _onDisposeObserver;
  50124. /**
  50125. * Back compatibility with callback before the onDisposeObservable existed.
  50126. * The set callback will be triggered when the layer has been disposed.
  50127. */
  50128. onDispose: () => void;
  50129. /**
  50130. * An event triggered before rendering the scene
  50131. */
  50132. onBeforeRenderObservable: Observable<Layer>;
  50133. private _onBeforeRenderObserver;
  50134. /**
  50135. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50136. * The set callback will be triggered just before rendering the layer.
  50137. */
  50138. onBeforeRender: () => void;
  50139. /**
  50140. * An event triggered after rendering the scene
  50141. */
  50142. onAfterRenderObservable: Observable<Layer>;
  50143. private _onAfterRenderObserver;
  50144. /**
  50145. * Back compatibility with callback before the onAfterRenderObservable existed.
  50146. * The set callback will be triggered just after rendering the layer.
  50147. */
  50148. onAfterRender: () => void;
  50149. /**
  50150. * Instantiates a new layer.
  50151. * This represents a full screen 2d layer.
  50152. * This can be useful to display a picture in the background of your scene for instance.
  50153. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50154. * @param name Define the name of the layer in the scene
  50155. * @param imgUrl Define the url of the texture to display in the layer
  50156. * @param scene Define the scene the layer belongs to
  50157. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50158. * @param color Defines a color for the layer
  50159. */
  50160. constructor(
  50161. /**
  50162. * Define the name of the layer.
  50163. */
  50164. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50165. private _createIndexBuffer;
  50166. /** @hidden */
  50167. _rebuild(): void;
  50168. /**
  50169. * Renders the layer in the scene.
  50170. */
  50171. render(): void;
  50172. /**
  50173. * Disposes and releases the associated ressources.
  50174. */
  50175. dispose(): void;
  50176. }
  50177. }
  50178. declare module BABYLON {
  50179. /** @hidden */
  50180. export var lensFlarePixelShader: {
  50181. name: string;
  50182. shader: string;
  50183. };
  50184. }
  50185. declare module BABYLON {
  50186. /** @hidden */
  50187. export var lensFlareVertexShader: {
  50188. name: string;
  50189. shader: string;
  50190. };
  50191. }
  50192. declare module BABYLON {
  50193. /**
  50194. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50195. * It is usually composed of several `lensFlare`.
  50196. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50197. */
  50198. export class LensFlareSystem {
  50199. /**
  50200. * Define the name of the lens flare system
  50201. */
  50202. name: string;
  50203. /**
  50204. * List of lens flares used in this system.
  50205. */
  50206. lensFlares: LensFlare[];
  50207. /**
  50208. * Define a limit from the border the lens flare can be visible.
  50209. */
  50210. borderLimit: number;
  50211. /**
  50212. * Define a viewport border we do not want to see the lens flare in.
  50213. */
  50214. viewportBorder: number;
  50215. /**
  50216. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50217. */
  50218. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50219. /**
  50220. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50221. */
  50222. layerMask: number;
  50223. /**
  50224. * Define the id of the lens flare system in the scene.
  50225. * (equal to name by default)
  50226. */
  50227. id: string;
  50228. private _scene;
  50229. private _emitter;
  50230. private _vertexBuffers;
  50231. private _indexBuffer;
  50232. private _effect;
  50233. private _positionX;
  50234. private _positionY;
  50235. private _isEnabled;
  50236. /** @hidden */
  50237. static _SceneComponentInitialization: (scene: Scene) => void;
  50238. /**
  50239. * Instantiates a lens flare system.
  50240. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50241. * It is usually composed of several `lensFlare`.
  50242. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50243. * @param name Define the name of the lens flare system in the scene
  50244. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50245. * @param scene Define the scene the lens flare system belongs to
  50246. */
  50247. constructor(
  50248. /**
  50249. * Define the name of the lens flare system
  50250. */
  50251. name: string, emitter: any, scene: Scene);
  50252. /**
  50253. * Define if the lens flare system is enabled.
  50254. */
  50255. isEnabled: boolean;
  50256. /**
  50257. * Get the scene the effects belongs to.
  50258. * @returns the scene holding the lens flare system
  50259. */
  50260. getScene(): Scene;
  50261. /**
  50262. * Get the emitter of the lens flare system.
  50263. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50264. * @returns the emitter of the lens flare system
  50265. */
  50266. getEmitter(): any;
  50267. /**
  50268. * Set the emitter of the lens flare system.
  50269. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50270. * @param newEmitter Define the new emitter of the system
  50271. */
  50272. setEmitter(newEmitter: any): void;
  50273. /**
  50274. * Get the lens flare system emitter position.
  50275. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50276. * @returns the position
  50277. */
  50278. getEmitterPosition(): Vector3;
  50279. /**
  50280. * @hidden
  50281. */
  50282. computeEffectivePosition(globalViewport: Viewport): boolean;
  50283. /** @hidden */
  50284. _isVisible(): boolean;
  50285. /**
  50286. * @hidden
  50287. */
  50288. render(): boolean;
  50289. /**
  50290. * Dispose and release the lens flare with its associated resources.
  50291. */
  50292. dispose(): void;
  50293. /**
  50294. * Parse a lens flare system from a JSON repressentation
  50295. * @param parsedLensFlareSystem Define the JSON to parse
  50296. * @param scene Define the scene the parsed system should be instantiated in
  50297. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50298. * @returns the parsed system
  50299. */
  50300. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50301. /**
  50302. * Serialize the current Lens Flare System into a JSON representation.
  50303. * @returns the serialized JSON
  50304. */
  50305. serialize(): any;
  50306. }
  50307. }
  50308. declare module BABYLON {
  50309. /**
  50310. * This represents one of the lens effect in a `lensFlareSystem`.
  50311. * It controls one of the indiviual texture used in the effect.
  50312. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50313. */
  50314. export class LensFlare {
  50315. /**
  50316. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50317. */
  50318. size: number;
  50319. /**
  50320. * 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.
  50321. */
  50322. position: number;
  50323. /**
  50324. * Define the lens color.
  50325. */
  50326. color: Color3;
  50327. /**
  50328. * Define the lens texture.
  50329. */
  50330. texture: Nullable<Texture>;
  50331. /**
  50332. * Define the alpha mode to render this particular lens.
  50333. */
  50334. alphaMode: number;
  50335. private _system;
  50336. /**
  50337. * Creates a new Lens Flare.
  50338. * This represents one of the lens effect in a `lensFlareSystem`.
  50339. * It controls one of the indiviual texture used in the effect.
  50340. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50341. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50342. * @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.
  50343. * @param color Define the lens color
  50344. * @param imgUrl Define the lens texture url
  50345. * @param system Define the `lensFlareSystem` this flare is part of
  50346. * @returns The newly created Lens Flare
  50347. */
  50348. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50349. /**
  50350. * Instantiates a new Lens Flare.
  50351. * This represents one of the lens effect in a `lensFlareSystem`.
  50352. * It controls one of the indiviual texture used in the effect.
  50353. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50354. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50355. * @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.
  50356. * @param color Define the lens color
  50357. * @param imgUrl Define the lens texture url
  50358. * @param system Define the `lensFlareSystem` this flare is part of
  50359. */
  50360. constructor(
  50361. /**
  50362. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50363. */
  50364. size: number,
  50365. /**
  50366. * 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.
  50367. */
  50368. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50369. /**
  50370. * Dispose and release the lens flare with its associated resources.
  50371. */
  50372. dispose(): void;
  50373. }
  50374. }
  50375. declare module BABYLON {
  50376. interface AbstractScene {
  50377. /**
  50378. * The list of lens flare system added to the scene
  50379. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50380. */
  50381. lensFlareSystems: Array<LensFlareSystem>;
  50382. /**
  50383. * Removes the given lens flare system from this scene.
  50384. * @param toRemove The lens flare system to remove
  50385. * @returns The index of the removed lens flare system
  50386. */
  50387. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50388. /**
  50389. * Adds the given lens flare system to this scene
  50390. * @param newLensFlareSystem The lens flare system to add
  50391. */
  50392. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50393. /**
  50394. * Gets a lens flare system using its name
  50395. * @param name defines the name to look for
  50396. * @returns the lens flare system or null if not found
  50397. */
  50398. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50399. /**
  50400. * Gets a lens flare system using its id
  50401. * @param id defines the id to look for
  50402. * @returns the lens flare system or null if not found
  50403. */
  50404. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50405. }
  50406. /**
  50407. * Defines the lens flare scene component responsible to manage any lens flares
  50408. * in a given scene.
  50409. */
  50410. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50411. /**
  50412. * The component name helpfull to identify the component in the list of scene components.
  50413. */
  50414. readonly name: string;
  50415. /**
  50416. * The scene the component belongs to.
  50417. */
  50418. scene: Scene;
  50419. /**
  50420. * Creates a new instance of the component for the given scene
  50421. * @param scene Defines the scene to register the component in
  50422. */
  50423. constructor(scene: Scene);
  50424. /**
  50425. * Registers the component in a given scene
  50426. */
  50427. register(): void;
  50428. /**
  50429. * Rebuilds the elements related to this component in case of
  50430. * context lost for instance.
  50431. */
  50432. rebuild(): void;
  50433. /**
  50434. * Adds all the elements from the container to the scene
  50435. * @param container the container holding the elements
  50436. */
  50437. addFromContainer(container: AbstractScene): void;
  50438. /**
  50439. * Removes all the elements in the container from the scene
  50440. * @param container contains the elements to remove
  50441. * @param dispose if the removed element should be disposed (default: false)
  50442. */
  50443. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50444. /**
  50445. * Serializes the component data to the specified json object
  50446. * @param serializationObject The object to serialize to
  50447. */
  50448. serialize(serializationObject: any): void;
  50449. /**
  50450. * Disposes the component and the associated ressources.
  50451. */
  50452. dispose(): void;
  50453. private _draw;
  50454. }
  50455. }
  50456. declare module BABYLON {
  50457. /**
  50458. * Defines the shadow generator component responsible to manage any shadow generators
  50459. * in a given scene.
  50460. */
  50461. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50462. /**
  50463. * The component name helpfull to identify the component in the list of scene components.
  50464. */
  50465. readonly name: string;
  50466. /**
  50467. * The scene the component belongs to.
  50468. */
  50469. scene: Scene;
  50470. /**
  50471. * Creates a new instance of the component for the given scene
  50472. * @param scene Defines the scene to register the component in
  50473. */
  50474. constructor(scene: Scene);
  50475. /**
  50476. * Registers the component in a given scene
  50477. */
  50478. register(): void;
  50479. /**
  50480. * Rebuilds the elements related to this component in case of
  50481. * context lost for instance.
  50482. */
  50483. rebuild(): void;
  50484. /**
  50485. * Serializes the component data to the specified json object
  50486. * @param serializationObject The object to serialize to
  50487. */
  50488. serialize(serializationObject: any): void;
  50489. /**
  50490. * Adds all the elements from the container to the scene
  50491. * @param container the container holding the elements
  50492. */
  50493. addFromContainer(container: AbstractScene): void;
  50494. /**
  50495. * Removes all the elements in the container from the scene
  50496. * @param container contains the elements to remove
  50497. * @param dispose if the removed element should be disposed (default: false)
  50498. */
  50499. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50500. /**
  50501. * Rebuilds the elements related to this component in case of
  50502. * context lost for instance.
  50503. */
  50504. dispose(): void;
  50505. private _gatherRenderTargets;
  50506. }
  50507. }
  50508. declare module BABYLON {
  50509. /**
  50510. * A point light is a light defined by an unique point in world space.
  50511. * The light is emitted in every direction from this point.
  50512. * A good example of a point light is a standard light bulb.
  50513. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50514. */
  50515. export class PointLight extends ShadowLight {
  50516. private _shadowAngle;
  50517. /**
  50518. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50519. * This specifies what angle the shadow will use to be created.
  50520. *
  50521. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50522. */
  50523. /**
  50524. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50525. * This specifies what angle the shadow will use to be created.
  50526. *
  50527. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50528. */
  50529. shadowAngle: number;
  50530. /**
  50531. * Gets the direction if it has been set.
  50532. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50533. */
  50534. /**
  50535. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50536. */
  50537. direction: Vector3;
  50538. /**
  50539. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50540. * A PointLight emits the light in every direction.
  50541. * It can cast shadows.
  50542. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50543. * ```javascript
  50544. * var pointLight = new PointLight("pl", camera.position, scene);
  50545. * ```
  50546. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50547. * @param name The light friendly name
  50548. * @param position The position of the point light in the scene
  50549. * @param scene The scene the lights belongs to
  50550. */
  50551. constructor(name: string, position: Vector3, scene: Scene);
  50552. /**
  50553. * Returns the string "PointLight"
  50554. * @returns the class name
  50555. */
  50556. getClassName(): string;
  50557. /**
  50558. * Returns the integer 0.
  50559. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50560. */
  50561. getTypeID(): number;
  50562. /**
  50563. * Specifies wether or not the shadowmap should be a cube texture.
  50564. * @returns true if the shadowmap needs to be a cube texture.
  50565. */
  50566. needCube(): boolean;
  50567. /**
  50568. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50569. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50570. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50571. */
  50572. getShadowDirection(faceIndex?: number): Vector3;
  50573. /**
  50574. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50575. * - fov = PI / 2
  50576. * - aspect ratio : 1.0
  50577. * - z-near and far equal to the active camera minZ and maxZ.
  50578. * Returns the PointLight.
  50579. */
  50580. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50581. protected _buildUniformLayout(): void;
  50582. /**
  50583. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50584. * @param effect The effect to update
  50585. * @param lightIndex The index of the light in the effect to update
  50586. * @returns The point light
  50587. */
  50588. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50589. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50590. /**
  50591. * Prepares the list of defines specific to the light type.
  50592. * @param defines the list of defines
  50593. * @param lightIndex defines the index of the light for the effect
  50594. */
  50595. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50596. }
  50597. }
  50598. declare module BABYLON {
  50599. /**
  50600. * Header information of HDR texture files.
  50601. */
  50602. export interface HDRInfo {
  50603. /**
  50604. * The height of the texture in pixels.
  50605. */
  50606. height: number;
  50607. /**
  50608. * The width of the texture in pixels.
  50609. */
  50610. width: number;
  50611. /**
  50612. * The index of the beginning of the data in the binary file.
  50613. */
  50614. dataPosition: number;
  50615. }
  50616. /**
  50617. * This groups tools to convert HDR texture to native colors array.
  50618. */
  50619. export class HDRTools {
  50620. private static Ldexp;
  50621. private static Rgbe2float;
  50622. private static readStringLine;
  50623. /**
  50624. * Reads header information from an RGBE texture stored in a native array.
  50625. * More information on this format are available here:
  50626. * https://en.wikipedia.org/wiki/RGBE_image_format
  50627. *
  50628. * @param uint8array The binary file stored in native array.
  50629. * @return The header information.
  50630. */
  50631. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50632. /**
  50633. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50634. * This RGBE texture needs to store the information as a panorama.
  50635. *
  50636. * More information on this format are available here:
  50637. * https://en.wikipedia.org/wiki/RGBE_image_format
  50638. *
  50639. * @param buffer The binary file stored in an array buffer.
  50640. * @param size The expected size of the extracted cubemap.
  50641. * @return The Cube Map information.
  50642. */
  50643. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50644. /**
  50645. * Returns the pixels data extracted from an RGBE texture.
  50646. * This pixels will be stored left to right up to down in the R G B order in one array.
  50647. *
  50648. * More information on this format are available here:
  50649. * https://en.wikipedia.org/wiki/RGBE_image_format
  50650. *
  50651. * @param uint8array The binary file stored in an array buffer.
  50652. * @param hdrInfo The header information of the file.
  50653. * @return The pixels data in RGB right to left up to down order.
  50654. */
  50655. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50656. private static RGBE_ReadPixels_RLE;
  50657. }
  50658. }
  50659. declare module BABYLON {
  50660. /**
  50661. * This represents a texture coming from an HDR input.
  50662. *
  50663. * The only supported format is currently panorama picture stored in RGBE format.
  50664. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50665. */
  50666. export class HDRCubeTexture extends BaseTexture {
  50667. private static _facesMapping;
  50668. private _generateHarmonics;
  50669. private _noMipmap;
  50670. private _textureMatrix;
  50671. private _size;
  50672. private _onLoad;
  50673. private _onError;
  50674. /**
  50675. * The texture URL.
  50676. */
  50677. url: string;
  50678. /**
  50679. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50680. */
  50681. coordinatesMode: number;
  50682. protected _isBlocking: boolean;
  50683. /**
  50684. * Sets wether or not the texture is blocking during loading.
  50685. */
  50686. /**
  50687. * Gets wether or not the texture is blocking during loading.
  50688. */
  50689. isBlocking: boolean;
  50690. protected _rotationY: number;
  50691. /**
  50692. * Sets texture matrix rotation angle around Y axis in radians.
  50693. */
  50694. /**
  50695. * Gets texture matrix rotation angle around Y axis radians.
  50696. */
  50697. rotationY: number;
  50698. /**
  50699. * Gets or sets the center of the bounding box associated with the cube texture
  50700. * It must define where the camera used to render the texture was set
  50701. */
  50702. boundingBoxPosition: Vector3;
  50703. private _boundingBoxSize;
  50704. /**
  50705. * Gets or sets the size of the bounding box associated with the cube texture
  50706. * When defined, the cubemap will switch to local mode
  50707. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50708. * @example https://www.babylonjs-playground.com/#RNASML
  50709. */
  50710. boundingBoxSize: Vector3;
  50711. /**
  50712. * Instantiates an HDRTexture from the following parameters.
  50713. *
  50714. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50715. * @param scene The scene the texture will be used in
  50716. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50717. * @param noMipmap Forces to not generate the mipmap if true
  50718. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50719. * @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)
  50720. * @param reserved Reserved flag for internal use.
  50721. */
  50722. 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>);
  50723. /**
  50724. * Get the current class name of the texture useful for serialization or dynamic coding.
  50725. * @returns "HDRCubeTexture"
  50726. */
  50727. getClassName(): string;
  50728. /**
  50729. * Occurs when the file is raw .hdr file.
  50730. */
  50731. private loadTexture;
  50732. clone(): HDRCubeTexture;
  50733. delayLoad(): void;
  50734. /**
  50735. * Get the texture reflection matrix used to rotate/transform the reflection.
  50736. * @returns the reflection matrix
  50737. */
  50738. getReflectionTextureMatrix(): Matrix;
  50739. /**
  50740. * Set the texture reflection matrix used to rotate/transform the reflection.
  50741. * @param value Define the reflection matrix to set
  50742. */
  50743. setReflectionTextureMatrix(value: Matrix): void;
  50744. /**
  50745. * Parses a JSON representation of an HDR Texture in order to create the texture
  50746. * @param parsedTexture Define the JSON representation
  50747. * @param scene Define the scene the texture should be created in
  50748. * @param rootUrl Define the root url in case we need to load relative dependencies
  50749. * @returns the newly created texture after parsing
  50750. */
  50751. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50752. serialize(): any;
  50753. }
  50754. }
  50755. declare module BABYLON {
  50756. /**
  50757. * Class used to control physics engine
  50758. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50759. */
  50760. export class PhysicsEngine implements IPhysicsEngine {
  50761. private _physicsPlugin;
  50762. /**
  50763. * Global value used to control the smallest number supported by the simulation
  50764. */
  50765. static Epsilon: number;
  50766. private _impostors;
  50767. private _joints;
  50768. /**
  50769. * Gets the gravity vector used by the simulation
  50770. */
  50771. gravity: Vector3;
  50772. /**
  50773. * Factory used to create the default physics plugin.
  50774. * @returns The default physics plugin
  50775. */
  50776. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50777. /**
  50778. * Creates a new Physics Engine
  50779. * @param gravity defines the gravity vector used by the simulation
  50780. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50781. */
  50782. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50783. /**
  50784. * Sets the gravity vector used by the simulation
  50785. * @param gravity defines the gravity vector to use
  50786. */
  50787. setGravity(gravity: Vector3): void;
  50788. /**
  50789. * Set the time step of the physics engine.
  50790. * Default is 1/60.
  50791. * To slow it down, enter 1/600 for example.
  50792. * To speed it up, 1/30
  50793. * @param newTimeStep defines the new timestep to apply to this world.
  50794. */
  50795. setTimeStep(newTimeStep?: number): void;
  50796. /**
  50797. * Get the time step of the physics engine.
  50798. * @returns the current time step
  50799. */
  50800. getTimeStep(): number;
  50801. /**
  50802. * Release all resources
  50803. */
  50804. dispose(): void;
  50805. /**
  50806. * Gets the name of the current physics plugin
  50807. * @returns the name of the plugin
  50808. */
  50809. getPhysicsPluginName(): string;
  50810. /**
  50811. * Adding a new impostor for the impostor tracking.
  50812. * This will be done by the impostor itself.
  50813. * @param impostor the impostor to add
  50814. */
  50815. addImpostor(impostor: PhysicsImpostor): void;
  50816. /**
  50817. * Remove an impostor from the engine.
  50818. * This impostor and its mesh will not longer be updated by the physics engine.
  50819. * @param impostor the impostor to remove
  50820. */
  50821. removeImpostor(impostor: PhysicsImpostor): void;
  50822. /**
  50823. * Add a joint to the physics engine
  50824. * @param mainImpostor defines the main impostor to which the joint is added.
  50825. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50826. * @param joint defines the joint that will connect both impostors.
  50827. */
  50828. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50829. /**
  50830. * Removes a joint from the simulation
  50831. * @param mainImpostor defines the impostor used with the joint
  50832. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50833. * @param joint defines the joint to remove
  50834. */
  50835. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50836. /**
  50837. * Called by the scene. No need to call it.
  50838. * @param delta defines the timespam between frames
  50839. */
  50840. _step(delta: number): void;
  50841. /**
  50842. * Gets the current plugin used to run the simulation
  50843. * @returns current plugin
  50844. */
  50845. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50846. /**
  50847. * Gets the list of physic impostors
  50848. * @returns an array of PhysicsImpostor
  50849. */
  50850. getImpostors(): Array<PhysicsImpostor>;
  50851. /**
  50852. * Gets the impostor for a physics enabled object
  50853. * @param object defines the object impersonated by the impostor
  50854. * @returns the PhysicsImpostor or null if not found
  50855. */
  50856. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50857. /**
  50858. * Gets the impostor for a physics body object
  50859. * @param body defines physics body used by the impostor
  50860. * @returns the PhysicsImpostor or null if not found
  50861. */
  50862. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50863. /**
  50864. * Does a raycast in the physics world
  50865. * @param from when should the ray start?
  50866. * @param to when should the ray end?
  50867. * @returns PhysicsRaycastResult
  50868. */
  50869. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50870. }
  50871. }
  50872. declare module BABYLON {
  50873. /** @hidden */
  50874. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50875. private _useDeltaForWorldStep;
  50876. world: any;
  50877. name: string;
  50878. private _physicsMaterials;
  50879. private _fixedTimeStep;
  50880. private _cannonRaycastResult;
  50881. private _raycastResult;
  50882. private _physicsBodysToRemoveAfterStep;
  50883. BJSCANNON: any;
  50884. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50885. setGravity(gravity: Vector3): void;
  50886. setTimeStep(timeStep: number): void;
  50887. getTimeStep(): number;
  50888. executeStep(delta: number): void;
  50889. private _removeMarkedPhysicsBodiesFromWorld;
  50890. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50891. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50892. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50893. private _processChildMeshes;
  50894. removePhysicsBody(impostor: PhysicsImpostor): void;
  50895. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50896. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50897. private _addMaterial;
  50898. private _checkWithEpsilon;
  50899. private _createShape;
  50900. private _createHeightmap;
  50901. private _minus90X;
  50902. private _plus90X;
  50903. private _tmpPosition;
  50904. private _tmpDeltaPosition;
  50905. private _tmpUnityRotation;
  50906. private _updatePhysicsBodyTransformation;
  50907. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50908. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50909. isSupported(): boolean;
  50910. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50911. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50912. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50913. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50914. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50915. getBodyMass(impostor: PhysicsImpostor): number;
  50916. getBodyFriction(impostor: PhysicsImpostor): number;
  50917. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50918. getBodyRestitution(impostor: PhysicsImpostor): number;
  50919. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50920. sleepBody(impostor: PhysicsImpostor): void;
  50921. wakeUpBody(impostor: PhysicsImpostor): void;
  50922. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50923. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50924. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50925. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50926. getRadius(impostor: PhysicsImpostor): number;
  50927. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50928. dispose(): void;
  50929. private _extendNamespace;
  50930. /**
  50931. * Does a raycast in the physics world
  50932. * @param from when should the ray start?
  50933. * @param to when should the ray end?
  50934. * @returns PhysicsRaycastResult
  50935. */
  50936. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50937. }
  50938. }
  50939. declare module BABYLON {
  50940. /** @hidden */
  50941. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50942. world: any;
  50943. name: string;
  50944. BJSOIMO: any;
  50945. private _raycastResult;
  50946. constructor(iterations?: number, oimoInjection?: any);
  50947. setGravity(gravity: Vector3): void;
  50948. setTimeStep(timeStep: number): void;
  50949. getTimeStep(): number;
  50950. private _tmpImpostorsArray;
  50951. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50952. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50953. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50954. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50955. private _tmpPositionVector;
  50956. removePhysicsBody(impostor: PhysicsImpostor): void;
  50957. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50958. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50959. isSupported(): boolean;
  50960. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50961. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50962. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50963. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50964. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50965. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50966. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50967. getBodyMass(impostor: PhysicsImpostor): number;
  50968. getBodyFriction(impostor: PhysicsImpostor): number;
  50969. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50970. getBodyRestitution(impostor: PhysicsImpostor): number;
  50971. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50972. sleepBody(impostor: PhysicsImpostor): void;
  50973. wakeUpBody(impostor: PhysicsImpostor): void;
  50974. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50975. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50976. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50977. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50978. getRadius(impostor: PhysicsImpostor): number;
  50979. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50980. dispose(): void;
  50981. /**
  50982. * Does a raycast in the physics world
  50983. * @param from when should the ray start?
  50984. * @param to when should the ray end?
  50985. * @returns PhysicsRaycastResult
  50986. */
  50987. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50988. }
  50989. }
  50990. declare module BABYLON {
  50991. /**
  50992. * Class containing static functions to help procedurally build meshes
  50993. */
  50994. export class RibbonBuilder {
  50995. /**
  50996. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50997. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50998. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50999. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51000. * * 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
  51001. * * 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
  51002. * * 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
  51003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51004. * * 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
  51005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51006. * * 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
  51007. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51008. * * 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
  51009. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51011. * @param name defines the name of the mesh
  51012. * @param options defines the options used to create the mesh
  51013. * @param scene defines the hosting scene
  51014. * @returns the ribbon mesh
  51015. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51016. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51017. */
  51018. static CreateRibbon(name: string, options: {
  51019. pathArray: Vector3[][];
  51020. closeArray?: boolean;
  51021. closePath?: boolean;
  51022. offset?: number;
  51023. updatable?: boolean;
  51024. sideOrientation?: number;
  51025. frontUVs?: Vector4;
  51026. backUVs?: Vector4;
  51027. instance?: Mesh;
  51028. invertUV?: boolean;
  51029. uvs?: Vector2[];
  51030. colors?: Color4[];
  51031. }, scene?: Nullable<Scene>): Mesh;
  51032. }
  51033. }
  51034. declare module BABYLON {
  51035. /**
  51036. * Class containing static functions to help procedurally build meshes
  51037. */
  51038. export class ShapeBuilder {
  51039. /**
  51040. * 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.
  51041. * * 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.
  51042. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51043. * * 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.
  51044. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51045. * * 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
  51046. * * 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
  51047. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51049. * * 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
  51050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51052. * @param name defines the name of the mesh
  51053. * @param options defines the options used to create the mesh
  51054. * @param scene defines the hosting scene
  51055. * @returns the extruded shape mesh
  51056. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51058. */
  51059. static ExtrudeShape(name: string, options: {
  51060. shape: Vector3[];
  51061. path: Vector3[];
  51062. scale?: number;
  51063. rotation?: number;
  51064. cap?: number;
  51065. updatable?: boolean;
  51066. sideOrientation?: number;
  51067. frontUVs?: Vector4;
  51068. backUVs?: Vector4;
  51069. instance?: Mesh;
  51070. invertUV?: boolean;
  51071. }, scene?: Nullable<Scene>): Mesh;
  51072. /**
  51073. * Creates an custom extruded shape mesh.
  51074. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51075. * * 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.
  51076. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51077. * * 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
  51078. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51079. * * 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
  51080. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51081. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51082. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51083. * * 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
  51084. * * 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
  51085. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51087. * * 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
  51088. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51090. * @param name defines the name of the mesh
  51091. * @param options defines the options used to create the mesh
  51092. * @param scene defines the hosting scene
  51093. * @returns the custom extruded shape mesh
  51094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51097. */
  51098. static ExtrudeShapeCustom(name: string, options: {
  51099. shape: Vector3[];
  51100. path: Vector3[];
  51101. scaleFunction?: any;
  51102. rotationFunction?: any;
  51103. ribbonCloseArray?: boolean;
  51104. ribbonClosePath?: boolean;
  51105. cap?: number;
  51106. updatable?: boolean;
  51107. sideOrientation?: number;
  51108. frontUVs?: Vector4;
  51109. backUVs?: Vector4;
  51110. instance?: Mesh;
  51111. invertUV?: boolean;
  51112. }, scene?: Nullable<Scene>): Mesh;
  51113. private static _ExtrudeShapeGeneric;
  51114. }
  51115. }
  51116. declare module BABYLON {
  51117. /**
  51118. * AmmoJS Physics plugin
  51119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51120. * @see https://github.com/kripken/ammo.js/
  51121. */
  51122. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51123. private _useDeltaForWorldStep;
  51124. /**
  51125. * Reference to the Ammo library
  51126. */
  51127. bjsAMMO: any;
  51128. /**
  51129. * Created ammoJS world which physics bodies are added to
  51130. */
  51131. world: any;
  51132. /**
  51133. * Name of the plugin
  51134. */
  51135. name: string;
  51136. private _timeStep;
  51137. private _fixedTimeStep;
  51138. private _maxSteps;
  51139. private _tmpQuaternion;
  51140. private _tmpAmmoTransform;
  51141. private _tmpAmmoQuaternion;
  51142. private _tmpAmmoConcreteContactResultCallback;
  51143. private _collisionConfiguration;
  51144. private _dispatcher;
  51145. private _overlappingPairCache;
  51146. private _solver;
  51147. private _softBodySolver;
  51148. private _tmpAmmoVectorA;
  51149. private _tmpAmmoVectorB;
  51150. private _tmpAmmoVectorC;
  51151. private _tmpAmmoVectorD;
  51152. private _tmpContactCallbackResult;
  51153. private _tmpAmmoVectorRCA;
  51154. private _tmpAmmoVectorRCB;
  51155. private _raycastResult;
  51156. private static readonly DISABLE_COLLISION_FLAG;
  51157. private static readonly KINEMATIC_FLAG;
  51158. private static readonly DISABLE_DEACTIVATION_FLAG;
  51159. /**
  51160. * Initializes the ammoJS plugin
  51161. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51162. * @param ammoInjection can be used to inject your own ammo reference
  51163. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51164. */
  51165. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51166. /**
  51167. * Sets the gravity of the physics world (m/(s^2))
  51168. * @param gravity Gravity to set
  51169. */
  51170. setGravity(gravity: Vector3): void;
  51171. /**
  51172. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51173. * @param timeStep timestep to use in seconds
  51174. */
  51175. setTimeStep(timeStep: number): void;
  51176. /**
  51177. * 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)
  51178. * @param fixedTimeStep fixedTimeStep to use in seconds
  51179. */
  51180. setFixedTimeStep(fixedTimeStep: number): void;
  51181. /**
  51182. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51183. * @param maxSteps the maximum number of steps by the physics engine per frame
  51184. */
  51185. setMaxSteps(maxSteps: number): void;
  51186. /**
  51187. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51188. * @returns the current timestep in seconds
  51189. */
  51190. getTimeStep(): number;
  51191. private _isImpostorInContact;
  51192. private _isImpostorPairInContact;
  51193. private _stepSimulation;
  51194. /**
  51195. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51196. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51197. * After the step the babylon meshes are set to the position of the physics imposters
  51198. * @param delta amount of time to step forward
  51199. * @param impostors array of imposters to update before/after the step
  51200. */
  51201. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51202. /**
  51203. * Update babylon mesh to match physics world object
  51204. * @param impostor imposter to match
  51205. */
  51206. private _afterSoftStep;
  51207. /**
  51208. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51209. * @param impostor imposter to match
  51210. */
  51211. private _ropeStep;
  51212. /**
  51213. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51214. * @param impostor imposter to match
  51215. */
  51216. private _softbodyOrClothStep;
  51217. private _tmpVector;
  51218. private _tmpMatrix;
  51219. /**
  51220. * Applies an impulse on the imposter
  51221. * @param impostor imposter to apply impulse to
  51222. * @param force amount of force to be applied to the imposter
  51223. * @param contactPoint the location to apply the impulse on the imposter
  51224. */
  51225. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51226. /**
  51227. * Applies a force on the imposter
  51228. * @param impostor imposter to apply force
  51229. * @param force amount of force to be applied to the imposter
  51230. * @param contactPoint the location to apply the force on the imposter
  51231. */
  51232. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51233. /**
  51234. * Creates a physics body using the plugin
  51235. * @param impostor the imposter to create the physics body on
  51236. */
  51237. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51238. /**
  51239. * Removes the physics body from the imposter and disposes of the body's memory
  51240. * @param impostor imposter to remove the physics body from
  51241. */
  51242. removePhysicsBody(impostor: PhysicsImpostor): void;
  51243. /**
  51244. * Generates a joint
  51245. * @param impostorJoint the imposter joint to create the joint with
  51246. */
  51247. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51248. /**
  51249. * Removes a joint
  51250. * @param impostorJoint the imposter joint to remove the joint from
  51251. */
  51252. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51253. private _addMeshVerts;
  51254. /**
  51255. * Initialise the soft body vertices to match its object's (mesh) vertices
  51256. * Softbody vertices (nodes) are in world space and to match this
  51257. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51258. * @param impostor to create the softbody for
  51259. */
  51260. private _softVertexData;
  51261. /**
  51262. * Create an impostor's soft body
  51263. * @param impostor to create the softbody for
  51264. */
  51265. private _createSoftbody;
  51266. /**
  51267. * Create cloth for an impostor
  51268. * @param impostor to create the softbody for
  51269. */
  51270. private _createCloth;
  51271. /**
  51272. * Create rope for an impostor
  51273. * @param impostor to create the softbody for
  51274. */
  51275. private _createRope;
  51276. private _addHullVerts;
  51277. private _createShape;
  51278. /**
  51279. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51280. * @param impostor imposter containing the physics body and babylon object
  51281. */
  51282. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51283. /**
  51284. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51285. * @param impostor imposter containing the physics body and babylon object
  51286. * @param newPosition new position
  51287. * @param newRotation new rotation
  51288. */
  51289. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51290. /**
  51291. * If this plugin is supported
  51292. * @returns true if its supported
  51293. */
  51294. isSupported(): boolean;
  51295. /**
  51296. * Sets the linear velocity of the physics body
  51297. * @param impostor imposter to set the velocity on
  51298. * @param velocity velocity to set
  51299. */
  51300. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51301. /**
  51302. * Sets the angular velocity of the physics body
  51303. * @param impostor imposter to set the velocity on
  51304. * @param velocity velocity to set
  51305. */
  51306. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51307. /**
  51308. * gets the linear velocity
  51309. * @param impostor imposter to get linear velocity from
  51310. * @returns linear velocity
  51311. */
  51312. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51313. /**
  51314. * gets the angular velocity
  51315. * @param impostor imposter to get angular velocity from
  51316. * @returns angular velocity
  51317. */
  51318. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51319. /**
  51320. * Sets the mass of physics body
  51321. * @param impostor imposter to set the mass on
  51322. * @param mass mass to set
  51323. */
  51324. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51325. /**
  51326. * Gets the mass of the physics body
  51327. * @param impostor imposter to get the mass from
  51328. * @returns mass
  51329. */
  51330. getBodyMass(impostor: PhysicsImpostor): number;
  51331. /**
  51332. * Gets friction of the impostor
  51333. * @param impostor impostor to get friction from
  51334. * @returns friction value
  51335. */
  51336. getBodyFriction(impostor: PhysicsImpostor): number;
  51337. /**
  51338. * Sets friction of the impostor
  51339. * @param impostor impostor to set friction on
  51340. * @param friction friction value
  51341. */
  51342. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51343. /**
  51344. * Gets restitution of the impostor
  51345. * @param impostor impostor to get restitution from
  51346. * @returns restitution value
  51347. */
  51348. getBodyRestitution(impostor: PhysicsImpostor): number;
  51349. /**
  51350. * Sets resitution of the impostor
  51351. * @param impostor impostor to set resitution on
  51352. * @param restitution resitution value
  51353. */
  51354. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51355. /**
  51356. * Gets pressure inside the impostor
  51357. * @param impostor impostor to get pressure from
  51358. * @returns pressure value
  51359. */
  51360. getBodyPressure(impostor: PhysicsImpostor): number;
  51361. /**
  51362. * Sets pressure inside a soft body impostor
  51363. * Cloth and rope must remain 0 pressure
  51364. * @param impostor impostor to set pressure on
  51365. * @param pressure pressure value
  51366. */
  51367. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51368. /**
  51369. * Gets stiffness of the impostor
  51370. * @param impostor impostor to get stiffness from
  51371. * @returns pressure value
  51372. */
  51373. getBodyStiffness(impostor: PhysicsImpostor): number;
  51374. /**
  51375. * Sets stiffness of the impostor
  51376. * @param impostor impostor to set stiffness on
  51377. * @param stiffness stiffness value from 0 to 1
  51378. */
  51379. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51380. /**
  51381. * Gets velocityIterations of the impostor
  51382. * @param impostor impostor to get velocity iterations from
  51383. * @returns velocityIterations value
  51384. */
  51385. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51386. /**
  51387. * Sets velocityIterations of the impostor
  51388. * @param impostor impostor to set velocity iterations on
  51389. * @param velocityIterations velocityIterations value
  51390. */
  51391. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51392. /**
  51393. * Gets positionIterations of the impostor
  51394. * @param impostor impostor to get position iterations from
  51395. * @returns positionIterations value
  51396. */
  51397. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51398. /**
  51399. * Sets positionIterations of the impostor
  51400. * @param impostor impostor to set position on
  51401. * @param positionIterations positionIterations value
  51402. */
  51403. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51404. /**
  51405. * Append an anchor to a cloth object
  51406. * @param impostor is the cloth impostor to add anchor to
  51407. * @param otherImpostor is the rigid impostor to anchor to
  51408. * @param width ratio across width from 0 to 1
  51409. * @param height ratio up height from 0 to 1
  51410. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51411. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51412. */
  51413. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51414. /**
  51415. * Append an hook to a rope object
  51416. * @param impostor is the rope impostor to add hook to
  51417. * @param otherImpostor is the rigid impostor to hook to
  51418. * @param length ratio along the rope from 0 to 1
  51419. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51420. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51421. */
  51422. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51423. /**
  51424. * Sleeps the physics body and stops it from being active
  51425. * @param impostor impostor to sleep
  51426. */
  51427. sleepBody(impostor: PhysicsImpostor): void;
  51428. /**
  51429. * Activates the physics body
  51430. * @param impostor impostor to activate
  51431. */
  51432. wakeUpBody(impostor: PhysicsImpostor): void;
  51433. /**
  51434. * Updates the distance parameters of the joint
  51435. * @param joint joint to update
  51436. * @param maxDistance maximum distance of the joint
  51437. * @param minDistance minimum distance of the joint
  51438. */
  51439. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51440. /**
  51441. * Sets a motor on the joint
  51442. * @param joint joint to set motor on
  51443. * @param speed speed of the motor
  51444. * @param maxForce maximum force of the motor
  51445. * @param motorIndex index of the motor
  51446. */
  51447. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51448. /**
  51449. * Sets the motors limit
  51450. * @param joint joint to set limit on
  51451. * @param upperLimit upper limit
  51452. * @param lowerLimit lower limit
  51453. */
  51454. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51455. /**
  51456. * Syncs the position and rotation of a mesh with the impostor
  51457. * @param mesh mesh to sync
  51458. * @param impostor impostor to update the mesh with
  51459. */
  51460. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51461. /**
  51462. * Gets the radius of the impostor
  51463. * @param impostor impostor to get radius from
  51464. * @returns the radius
  51465. */
  51466. getRadius(impostor: PhysicsImpostor): number;
  51467. /**
  51468. * Gets the box size of the impostor
  51469. * @param impostor impostor to get box size from
  51470. * @param result the resulting box size
  51471. */
  51472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51473. /**
  51474. * Disposes of the impostor
  51475. */
  51476. dispose(): void;
  51477. /**
  51478. * Does a raycast in the physics world
  51479. * @param from when should the ray start?
  51480. * @param to when should the ray end?
  51481. * @returns PhysicsRaycastResult
  51482. */
  51483. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51484. }
  51485. }
  51486. declare module BABYLON {
  51487. interface AbstractScene {
  51488. /**
  51489. * The list of reflection probes added to the scene
  51490. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51491. */
  51492. reflectionProbes: Array<ReflectionProbe>;
  51493. /**
  51494. * Removes the given reflection probe from this scene.
  51495. * @param toRemove The reflection probe to remove
  51496. * @returns The index of the removed reflection probe
  51497. */
  51498. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51499. /**
  51500. * Adds the given reflection probe to this scene.
  51501. * @param newReflectionProbe The reflection probe to add
  51502. */
  51503. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51504. }
  51505. /**
  51506. * Class used to generate realtime reflection / refraction cube textures
  51507. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51508. */
  51509. export class ReflectionProbe {
  51510. /** defines the name of the probe */
  51511. name: string;
  51512. private _scene;
  51513. private _renderTargetTexture;
  51514. private _projectionMatrix;
  51515. private _viewMatrix;
  51516. private _target;
  51517. private _add;
  51518. private _attachedMesh;
  51519. private _invertYAxis;
  51520. /** Gets or sets probe position (center of the cube map) */
  51521. position: Vector3;
  51522. /**
  51523. * Creates a new reflection probe
  51524. * @param name defines the name of the probe
  51525. * @param size defines the texture resolution (for each face)
  51526. * @param scene defines the hosting scene
  51527. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51528. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51529. */
  51530. constructor(
  51531. /** defines the name of the probe */
  51532. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51533. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51534. samples: number;
  51535. /** Gets or sets the refresh rate to use (on every frame by default) */
  51536. refreshRate: number;
  51537. /**
  51538. * Gets the hosting scene
  51539. * @returns a Scene
  51540. */
  51541. getScene(): Scene;
  51542. /** Gets the internal CubeTexture used to render to */
  51543. readonly cubeTexture: RenderTargetTexture;
  51544. /** Gets the list of meshes to render */
  51545. readonly renderList: Nullable<AbstractMesh[]>;
  51546. /**
  51547. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51548. * @param mesh defines the mesh to attach to
  51549. */
  51550. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51551. /**
  51552. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51553. * @param renderingGroupId The rendering group id corresponding to its index
  51554. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51555. */
  51556. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51557. /**
  51558. * Clean all associated resources
  51559. */
  51560. dispose(): void;
  51561. /**
  51562. * Converts the reflection probe information to a readable string for debug purpose.
  51563. * @param fullDetails Supports for multiple levels of logging within scene loading
  51564. * @returns the human readable reflection probe info
  51565. */
  51566. toString(fullDetails?: boolean): string;
  51567. /**
  51568. * Get the class name of the relfection probe.
  51569. * @returns "ReflectionProbe"
  51570. */
  51571. getClassName(): string;
  51572. /**
  51573. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51574. * @returns The JSON representation of the texture
  51575. */
  51576. serialize(): any;
  51577. /**
  51578. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51579. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51580. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51581. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51582. * @returns The parsed reflection probe if successful
  51583. */
  51584. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51585. }
  51586. }
  51587. declare module BABYLON {
  51588. /** @hidden */
  51589. export var _BabylonLoaderRegistered: boolean;
  51590. }
  51591. declare module BABYLON {
  51592. /**
  51593. * The Physically based simple base material of BJS.
  51594. *
  51595. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51596. * It is used as the base class for both the specGloss and metalRough conventions.
  51597. */
  51598. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51599. /**
  51600. * Number of Simultaneous lights allowed on the material.
  51601. */
  51602. maxSimultaneousLights: number;
  51603. /**
  51604. * If sets to true, disables all the lights affecting the material.
  51605. */
  51606. disableLighting: boolean;
  51607. /**
  51608. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51609. */
  51610. environmentTexture: BaseTexture;
  51611. /**
  51612. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51613. */
  51614. invertNormalMapX: boolean;
  51615. /**
  51616. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51617. */
  51618. invertNormalMapY: boolean;
  51619. /**
  51620. * Normal map used in the model.
  51621. */
  51622. normalTexture: BaseTexture;
  51623. /**
  51624. * Emissivie color used to self-illuminate the model.
  51625. */
  51626. emissiveColor: Color3;
  51627. /**
  51628. * Emissivie texture used to self-illuminate the model.
  51629. */
  51630. emissiveTexture: BaseTexture;
  51631. /**
  51632. * Occlusion Channel Strenght.
  51633. */
  51634. occlusionStrength: number;
  51635. /**
  51636. * Occlusion Texture of the material (adding extra occlusion effects).
  51637. */
  51638. occlusionTexture: BaseTexture;
  51639. /**
  51640. * Defines the alpha limits in alpha test mode.
  51641. */
  51642. alphaCutOff: number;
  51643. /**
  51644. * Gets the current double sided mode.
  51645. */
  51646. /**
  51647. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51648. */
  51649. doubleSided: boolean;
  51650. /**
  51651. * Stores the pre-calculated light information of a mesh in a texture.
  51652. */
  51653. lightmapTexture: BaseTexture;
  51654. /**
  51655. * If true, the light map contains occlusion information instead of lighting info.
  51656. */
  51657. useLightmapAsShadowmap: boolean;
  51658. /**
  51659. * Instantiates a new PBRMaterial instance.
  51660. *
  51661. * @param name The material name
  51662. * @param scene The scene the material will be use in.
  51663. */
  51664. constructor(name: string, scene: Scene);
  51665. getClassName(): string;
  51666. }
  51667. }
  51668. declare module BABYLON {
  51669. /**
  51670. * The PBR material of BJS following the metal roughness convention.
  51671. *
  51672. * This fits to the PBR convention in the GLTF definition:
  51673. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51674. */
  51675. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51676. /**
  51677. * The base color has two different interpretations depending on the value of metalness.
  51678. * When the material is a metal, the base color is the specific measured reflectance value
  51679. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51680. * of the material.
  51681. */
  51682. baseColor: Color3;
  51683. /**
  51684. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51685. * well as opacity information in the alpha channel.
  51686. */
  51687. baseTexture: BaseTexture;
  51688. /**
  51689. * Specifies the metallic scalar value of the material.
  51690. * Can also be used to scale the metalness values of the metallic texture.
  51691. */
  51692. metallic: number;
  51693. /**
  51694. * Specifies the roughness scalar value of the material.
  51695. * Can also be used to scale the roughness values of the metallic texture.
  51696. */
  51697. roughness: number;
  51698. /**
  51699. * Texture containing both the metallic value in the B channel and the
  51700. * roughness value in the G channel to keep better precision.
  51701. */
  51702. metallicRoughnessTexture: BaseTexture;
  51703. /**
  51704. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51705. *
  51706. * @param name The material name
  51707. * @param scene The scene the material will be use in.
  51708. */
  51709. constructor(name: string, scene: Scene);
  51710. /**
  51711. * Return the currrent class name of the material.
  51712. */
  51713. getClassName(): string;
  51714. /**
  51715. * Makes a duplicate of the current material.
  51716. * @param name - name to use for the new material.
  51717. */
  51718. clone(name: string): PBRMetallicRoughnessMaterial;
  51719. /**
  51720. * Serialize the material to a parsable JSON object.
  51721. */
  51722. serialize(): any;
  51723. /**
  51724. * Parses a JSON object correponding to the serialize function.
  51725. */
  51726. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51727. }
  51728. }
  51729. declare module BABYLON {
  51730. /**
  51731. * The PBR material of BJS following the specular glossiness convention.
  51732. *
  51733. * This fits to the PBR convention in the GLTF definition:
  51734. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51735. */
  51736. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51737. /**
  51738. * Specifies the diffuse color of the material.
  51739. */
  51740. diffuseColor: Color3;
  51741. /**
  51742. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51743. * channel.
  51744. */
  51745. diffuseTexture: BaseTexture;
  51746. /**
  51747. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51748. */
  51749. specularColor: Color3;
  51750. /**
  51751. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51752. */
  51753. glossiness: number;
  51754. /**
  51755. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51756. */
  51757. specularGlossinessTexture: BaseTexture;
  51758. /**
  51759. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51760. *
  51761. * @param name The material name
  51762. * @param scene The scene the material will be use in.
  51763. */
  51764. constructor(name: string, scene: Scene);
  51765. /**
  51766. * Return the currrent class name of the material.
  51767. */
  51768. getClassName(): string;
  51769. /**
  51770. * Makes a duplicate of the current material.
  51771. * @param name - name to use for the new material.
  51772. */
  51773. clone(name: string): PBRSpecularGlossinessMaterial;
  51774. /**
  51775. * Serialize the material to a parsable JSON object.
  51776. */
  51777. serialize(): any;
  51778. /**
  51779. * Parses a JSON object correponding to the serialize function.
  51780. */
  51781. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51782. }
  51783. }
  51784. declare module BABYLON {
  51785. /**
  51786. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51787. * It can help converting any input color in a desired output one. This can then be used to create effects
  51788. * from sepia, black and white to sixties or futuristic rendering...
  51789. *
  51790. * The only supported format is currently 3dl.
  51791. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51792. */
  51793. export class ColorGradingTexture extends BaseTexture {
  51794. /**
  51795. * The current texture matrix. (will always be identity in color grading texture)
  51796. */
  51797. private _textureMatrix;
  51798. /**
  51799. * The texture URL.
  51800. */
  51801. url: string;
  51802. /**
  51803. * Empty line regex stored for GC.
  51804. */
  51805. private static _noneEmptyLineRegex;
  51806. private _engine;
  51807. /**
  51808. * Instantiates a ColorGradingTexture from the following parameters.
  51809. *
  51810. * @param url The location of the color gradind data (currently only supporting 3dl)
  51811. * @param scene The scene the texture will be used in
  51812. */
  51813. constructor(url: string, scene: Scene);
  51814. /**
  51815. * Returns the texture matrix used in most of the material.
  51816. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51817. */
  51818. getTextureMatrix(): Matrix;
  51819. /**
  51820. * Occurs when the file being loaded is a .3dl LUT file.
  51821. */
  51822. private load3dlTexture;
  51823. /**
  51824. * Starts the loading process of the texture.
  51825. */
  51826. private loadTexture;
  51827. /**
  51828. * Clones the color gradind texture.
  51829. */
  51830. clone(): ColorGradingTexture;
  51831. /**
  51832. * Called during delayed load for textures.
  51833. */
  51834. delayLoad(): void;
  51835. /**
  51836. * Parses a color grading texture serialized by Babylon.
  51837. * @param parsedTexture The texture information being parsedTexture
  51838. * @param scene The scene to load the texture in
  51839. * @param rootUrl The root url of the data assets to load
  51840. * @return A color gradind texture
  51841. */
  51842. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51843. /**
  51844. * Serializes the LUT texture to json format.
  51845. */
  51846. serialize(): any;
  51847. }
  51848. }
  51849. declare module BABYLON {
  51850. /**
  51851. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51852. */
  51853. export class EquiRectangularCubeTexture extends BaseTexture {
  51854. /** The six faces of the cube. */
  51855. private static _FacesMapping;
  51856. private _noMipmap;
  51857. private _onLoad;
  51858. private _onError;
  51859. /** The size of the cubemap. */
  51860. private _size;
  51861. /** The buffer of the image. */
  51862. private _buffer;
  51863. /** The width of the input image. */
  51864. private _width;
  51865. /** The height of the input image. */
  51866. private _height;
  51867. /** The URL to the image. */
  51868. url: string;
  51869. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51870. coordinatesMode: number;
  51871. /**
  51872. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51873. * @param url The location of the image
  51874. * @param scene The scene the texture will be used in
  51875. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51876. * @param noMipmap Forces to not generate the mipmap if true
  51877. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51878. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51879. * @param onLoad — defines a callback called when texture is loaded
  51880. * @param onError — defines a callback called if there is an error
  51881. */
  51882. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51883. /**
  51884. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51885. */
  51886. private loadImage;
  51887. /**
  51888. * Convert the image buffer into a cubemap and create a CubeTexture.
  51889. */
  51890. private loadTexture;
  51891. /**
  51892. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51893. * @param buffer The ArrayBuffer that should be converted.
  51894. * @returns The buffer as Float32Array.
  51895. */
  51896. private getFloat32ArrayFromArrayBuffer;
  51897. /**
  51898. * Get the current class name of the texture useful for serialization or dynamic coding.
  51899. * @returns "EquiRectangularCubeTexture"
  51900. */
  51901. getClassName(): string;
  51902. /**
  51903. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51904. * @returns A clone of the current EquiRectangularCubeTexture.
  51905. */
  51906. clone(): EquiRectangularCubeTexture;
  51907. }
  51908. }
  51909. declare module BABYLON {
  51910. /**
  51911. * Based on jsTGALoader - Javascript loader for TGA file
  51912. * By Vincent Thibault
  51913. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51914. */
  51915. export class TGATools {
  51916. private static _TYPE_INDEXED;
  51917. private static _TYPE_RGB;
  51918. private static _TYPE_GREY;
  51919. private static _TYPE_RLE_INDEXED;
  51920. private static _TYPE_RLE_RGB;
  51921. private static _TYPE_RLE_GREY;
  51922. private static _ORIGIN_MASK;
  51923. private static _ORIGIN_SHIFT;
  51924. private static _ORIGIN_BL;
  51925. private static _ORIGIN_BR;
  51926. private static _ORIGIN_UL;
  51927. private static _ORIGIN_UR;
  51928. /**
  51929. * Gets the header of a TGA file
  51930. * @param data defines the TGA data
  51931. * @returns the header
  51932. */
  51933. static GetTGAHeader(data: Uint8Array): any;
  51934. /**
  51935. * Uploads TGA content to a Babylon Texture
  51936. * @hidden
  51937. */
  51938. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51939. /** @hidden */
  51940. 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;
  51941. /** @hidden */
  51942. 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;
  51943. /** @hidden */
  51944. 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;
  51945. /** @hidden */
  51946. 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;
  51947. /** @hidden */
  51948. 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;
  51949. /** @hidden */
  51950. 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;
  51951. }
  51952. }
  51953. declare module BABYLON {
  51954. /**
  51955. * Implementation of the TGA Texture Loader.
  51956. * @hidden
  51957. */
  51958. export class _TGATextureLoader implements IInternalTextureLoader {
  51959. /**
  51960. * Defines wether the loader supports cascade loading the different faces.
  51961. */
  51962. readonly supportCascades: boolean;
  51963. /**
  51964. * This returns if the loader support the current file information.
  51965. * @param extension defines the file extension of the file being loaded
  51966. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51967. * @param fallback defines the fallback internal texture if any
  51968. * @param isBase64 defines whether the texture is encoded as a base64
  51969. * @param isBuffer defines whether the texture data are stored as a buffer
  51970. * @returns true if the loader can load the specified file
  51971. */
  51972. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51973. /**
  51974. * Transform the url before loading if required.
  51975. * @param rootUrl the url of the texture
  51976. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51977. * @returns the transformed texture
  51978. */
  51979. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51980. /**
  51981. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51982. * @param rootUrl the url of the texture
  51983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51984. * @returns the fallback texture
  51985. */
  51986. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51987. /**
  51988. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51989. * @param data contains the texture data
  51990. * @param texture defines the BabylonJS internal texture
  51991. * @param createPolynomials will be true if polynomials have been requested
  51992. * @param onLoad defines the callback to trigger once the texture is ready
  51993. * @param onError defines the callback to trigger in case of error
  51994. */
  51995. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51996. /**
  51997. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51998. * @param data contains the texture data
  51999. * @param texture defines the BabylonJS internal texture
  52000. * @param callback defines the method to call once ready to upload
  52001. */
  52002. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52003. }
  52004. }
  52005. declare module BABYLON {
  52006. /**
  52007. * Info about the .basis files
  52008. */
  52009. class BasisFileInfo {
  52010. /**
  52011. * If the file has alpha
  52012. */
  52013. hasAlpha: boolean;
  52014. /**
  52015. * Info about each image of the basis file
  52016. */
  52017. images: Array<{
  52018. levels: Array<{
  52019. width: number;
  52020. height: number;
  52021. transcodedPixels: ArrayBufferView;
  52022. }>;
  52023. }>;
  52024. }
  52025. /**
  52026. * Result of transcoding a basis file
  52027. */
  52028. class TranscodeResult {
  52029. /**
  52030. * Info about the .basis file
  52031. */
  52032. fileInfo: BasisFileInfo;
  52033. /**
  52034. * Format to use when loading the file
  52035. */
  52036. format: number;
  52037. }
  52038. /**
  52039. * Configuration options for the Basis transcoder
  52040. */
  52041. export class BasisTranscodeConfiguration {
  52042. /**
  52043. * Supported compression formats used to determine the supported output format of the transcoder
  52044. */
  52045. supportedCompressionFormats?: {
  52046. /**
  52047. * etc1 compression format
  52048. */
  52049. etc1?: boolean;
  52050. /**
  52051. * s3tc compression format
  52052. */
  52053. s3tc?: boolean;
  52054. /**
  52055. * pvrtc compression format
  52056. */
  52057. pvrtc?: boolean;
  52058. /**
  52059. * etc2 compression format
  52060. */
  52061. etc2?: boolean;
  52062. };
  52063. /**
  52064. * If mipmap levels should be loaded for transcoded images (Default: true)
  52065. */
  52066. loadMipmapLevels?: boolean;
  52067. /**
  52068. * Index of a single image to load (Default: all images)
  52069. */
  52070. loadSingleImage?: number;
  52071. }
  52072. /**
  52073. * Used to load .Basis files
  52074. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52075. */
  52076. export class BasisTools {
  52077. private static _IgnoreSupportedFormats;
  52078. /**
  52079. * URL to use when loading the basis transcoder
  52080. */
  52081. static JSModuleURL: string;
  52082. /**
  52083. * URL to use when loading the wasm module for the transcoder
  52084. */
  52085. static WasmModuleURL: string;
  52086. /**
  52087. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52088. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52089. * @returns internal format corresponding to the Basis format
  52090. */
  52091. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52092. private static _WorkerPromise;
  52093. private static _Worker;
  52094. private static _actionId;
  52095. private static _CreateWorkerAsync;
  52096. /**
  52097. * Transcodes a loaded image file to compressed pixel data
  52098. * @param imageData image data to transcode
  52099. * @param config configuration options for the transcoding
  52100. * @returns a promise resulting in the transcoded image
  52101. */
  52102. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52103. /**
  52104. * Loads a texture from the transcode result
  52105. * @param texture texture load to
  52106. * @param transcodeResult the result of transcoding the basis file to load from
  52107. */
  52108. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52109. }
  52110. }
  52111. declare module BABYLON {
  52112. /**
  52113. * Loader for .basis file format
  52114. */
  52115. export class _BasisTextureLoader implements IInternalTextureLoader {
  52116. /**
  52117. * Defines whether the loader supports cascade loading the different faces.
  52118. */
  52119. readonly supportCascades: boolean;
  52120. /**
  52121. * This returns if the loader support the current file information.
  52122. * @param extension defines the file extension of the file being loaded
  52123. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52124. * @param fallback defines the fallback internal texture if any
  52125. * @param isBase64 defines whether the texture is encoded as a base64
  52126. * @param isBuffer defines whether the texture data are stored as a buffer
  52127. * @returns true if the loader can load the specified file
  52128. */
  52129. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52130. /**
  52131. * Transform the url before loading if required.
  52132. * @param rootUrl the url of the texture
  52133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52134. * @returns the transformed texture
  52135. */
  52136. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52137. /**
  52138. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52139. * @param rootUrl the url of the texture
  52140. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52141. * @returns the fallback texture
  52142. */
  52143. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52144. /**
  52145. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52146. * @param data contains the texture data
  52147. * @param texture defines the BabylonJS internal texture
  52148. * @param createPolynomials will be true if polynomials have been requested
  52149. * @param onLoad defines the callback to trigger once the texture is ready
  52150. * @param onError defines the callback to trigger in case of error
  52151. */
  52152. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52153. /**
  52154. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52155. * @param data contains the texture data
  52156. * @param texture defines the BabylonJS internal texture
  52157. * @param callback defines the method to call once ready to upload
  52158. */
  52159. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52160. }
  52161. }
  52162. declare module BABYLON {
  52163. /**
  52164. * 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.
  52165. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52166. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52167. */
  52168. export class CustomProceduralTexture extends ProceduralTexture {
  52169. private _animate;
  52170. private _time;
  52171. private _config;
  52172. private _texturePath;
  52173. /**
  52174. * Instantiates a new Custom Procedural Texture.
  52175. * 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.
  52176. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52177. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52178. * @param name Define the name of the texture
  52179. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52180. * @param size Define the size of the texture to create
  52181. * @param scene Define the scene the texture belongs to
  52182. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52183. * @param generateMipMaps Define if the texture should creates mip maps or not
  52184. */
  52185. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52186. private _loadJson;
  52187. /**
  52188. * Is the texture ready to be used ? (rendered at least once)
  52189. * @returns true if ready, otherwise, false.
  52190. */
  52191. isReady(): boolean;
  52192. /**
  52193. * Render the texture to its associated render target.
  52194. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52195. */
  52196. render(useCameraPostProcess?: boolean): void;
  52197. /**
  52198. * Update the list of dependant textures samplers in the shader.
  52199. */
  52200. updateTextures(): void;
  52201. /**
  52202. * Update the uniform values of the procedural texture in the shader.
  52203. */
  52204. updateShaderUniforms(): void;
  52205. /**
  52206. * Define if the texture animates or not.
  52207. */
  52208. animate: boolean;
  52209. }
  52210. }
  52211. declare module BABYLON {
  52212. /** @hidden */
  52213. export var noisePixelShader: {
  52214. name: string;
  52215. shader: string;
  52216. };
  52217. }
  52218. declare module BABYLON {
  52219. /**
  52220. * Class used to generate noise procedural textures
  52221. */
  52222. export class NoiseProceduralTexture extends ProceduralTexture {
  52223. private _time;
  52224. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52225. brightness: number;
  52226. /** Defines the number of octaves to process */
  52227. octaves: number;
  52228. /** Defines the level of persistence (0.8 by default) */
  52229. persistence: number;
  52230. /** Gets or sets animation speed factor (default is 1) */
  52231. animationSpeedFactor: number;
  52232. /**
  52233. * Creates a new NoiseProceduralTexture
  52234. * @param name defines the name fo the texture
  52235. * @param size defines the size of the texture (default is 256)
  52236. * @param scene defines the hosting scene
  52237. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52238. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52239. */
  52240. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52241. private _updateShaderUniforms;
  52242. protected _getDefines(): string;
  52243. /** Generate the current state of the procedural texture */
  52244. render(useCameraPostProcess?: boolean): void;
  52245. /**
  52246. * Serializes this noise procedural texture
  52247. * @returns a serialized noise procedural texture object
  52248. */
  52249. serialize(): any;
  52250. /**
  52251. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52252. * @param parsedTexture defines parsed texture data
  52253. * @param scene defines the current scene
  52254. * @param rootUrl defines the root URL containing noise procedural texture information
  52255. * @returns a parsed NoiseProceduralTexture
  52256. */
  52257. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52258. }
  52259. }
  52260. declare module BABYLON {
  52261. /**
  52262. * Raw cube texture where the raw buffers are passed in
  52263. */
  52264. export class RawCubeTexture extends CubeTexture {
  52265. /**
  52266. * Creates a cube texture where the raw buffers are passed in.
  52267. * @param scene defines the scene the texture is attached to
  52268. * @param data defines the array of data to use to create each face
  52269. * @param size defines the size of the textures
  52270. * @param format defines the format of the data
  52271. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52272. * @param generateMipMaps defines if the engine should generate the mip levels
  52273. * @param invertY defines if data must be stored with Y axis inverted
  52274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52275. * @param compression defines the compression used (null by default)
  52276. */
  52277. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52278. /**
  52279. * Updates the raw cube texture.
  52280. * @param data defines the data to store
  52281. * @param format defines the data format
  52282. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52283. * @param invertY defines if data must be stored with Y axis inverted
  52284. * @param compression defines the compression used (null by default)
  52285. * @param level defines which level of the texture to update
  52286. */
  52287. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52288. /**
  52289. * Updates a raw cube texture with RGBD encoded data.
  52290. * @param data defines the array of data [mipmap][face] to use to create each face
  52291. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52292. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52293. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52294. * @returns a promsie that resolves when the operation is complete
  52295. */
  52296. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52297. /**
  52298. * Clones the raw cube texture.
  52299. * @return a new cube texture
  52300. */
  52301. clone(): CubeTexture;
  52302. /** @hidden */
  52303. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52304. }
  52305. }
  52306. declare module BABYLON {
  52307. /**
  52308. * Class used to store 3D textures containing user data
  52309. */
  52310. export class RawTexture3D extends Texture {
  52311. /** Gets or sets the texture format to use */
  52312. format: number;
  52313. private _engine;
  52314. /**
  52315. * Create a new RawTexture3D
  52316. * @param data defines the data of the texture
  52317. * @param width defines the width of the texture
  52318. * @param height defines the height of the texture
  52319. * @param depth defines the depth of the texture
  52320. * @param format defines the texture format to use
  52321. * @param scene defines the hosting scene
  52322. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52323. * @param invertY defines if texture must be stored with Y axis inverted
  52324. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52325. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52326. */
  52327. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52328. /** Gets or sets the texture format to use */
  52329. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52330. /**
  52331. * Update the texture with new data
  52332. * @param data defines the data to store in the texture
  52333. */
  52334. update(data: ArrayBufferView): void;
  52335. }
  52336. }
  52337. declare module BABYLON {
  52338. /**
  52339. * Creates a refraction texture used by refraction channel of the standard material.
  52340. * It is like a mirror but to see through a material.
  52341. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52342. */
  52343. export class RefractionTexture extends RenderTargetTexture {
  52344. /**
  52345. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52346. * 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.
  52347. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52348. */
  52349. refractionPlane: Plane;
  52350. /**
  52351. * Define how deep under the surface we should see.
  52352. */
  52353. depth: number;
  52354. /**
  52355. * Creates a refraction texture used by refraction channel of the standard material.
  52356. * It is like a mirror but to see through a material.
  52357. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52358. * @param name Define the texture name
  52359. * @param size Define the size of the underlying texture
  52360. * @param scene Define the scene the refraction belongs to
  52361. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52362. */
  52363. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52364. /**
  52365. * Clone the refraction texture.
  52366. * @returns the cloned texture
  52367. */
  52368. clone(): RefractionTexture;
  52369. /**
  52370. * Serialize the texture to a JSON representation you could use in Parse later on
  52371. * @returns the serialized JSON representation
  52372. */
  52373. serialize(): any;
  52374. }
  52375. }
  52376. declare module BABYLON {
  52377. /**
  52378. * Defines the options related to the creation of an HtmlElementTexture
  52379. */
  52380. export interface IHtmlElementTextureOptions {
  52381. /**
  52382. * Defines wether mip maps should be created or not.
  52383. */
  52384. generateMipMaps?: boolean;
  52385. /**
  52386. * Defines the sampling mode of the texture.
  52387. */
  52388. samplingMode?: number;
  52389. /**
  52390. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52391. */
  52392. engine: Nullable<Engine>;
  52393. /**
  52394. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52395. */
  52396. scene: Nullable<Scene>;
  52397. }
  52398. /**
  52399. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52400. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52401. * is automatically managed.
  52402. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52403. * in your application.
  52404. *
  52405. * As the update is not automatic, you need to call them manually.
  52406. */
  52407. export class HtmlElementTexture extends BaseTexture {
  52408. /**
  52409. * The texture URL.
  52410. */
  52411. element: HTMLVideoElement | HTMLCanvasElement;
  52412. private static readonly DefaultOptions;
  52413. private _textureMatrix;
  52414. private _engine;
  52415. private _isVideo;
  52416. private _generateMipMaps;
  52417. private _samplingMode;
  52418. /**
  52419. * Instantiates a HtmlElementTexture from the following parameters.
  52420. *
  52421. * @param name Defines the name of the texture
  52422. * @param element Defines the video or canvas the texture is filled with
  52423. * @param options Defines the other none mandatory texture creation options
  52424. */
  52425. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52426. private _createInternalTexture;
  52427. /**
  52428. * Returns the texture matrix used in most of the material.
  52429. */
  52430. getTextureMatrix(): Matrix;
  52431. /**
  52432. * Updates the content of the texture.
  52433. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52434. */
  52435. update(invertY?: Nullable<boolean>): void;
  52436. }
  52437. }
  52438. declare module BABYLON {
  52439. /**
  52440. * Enum used to define the target of a block
  52441. */
  52442. export enum NodeMaterialBlockTargets {
  52443. /** Vertex shader */
  52444. Vertex = 1,
  52445. /** Fragment shader */
  52446. Fragment = 2,
  52447. /** Neutral */
  52448. Neutral = 4,
  52449. /** Vertex and Fragment */
  52450. VertexAndFragment = 3
  52451. }
  52452. }
  52453. declare module BABYLON {
  52454. /**
  52455. * Defines the kind of connection point for node based material
  52456. */
  52457. export enum NodeMaterialBlockConnectionPointTypes {
  52458. /** Float */
  52459. Float = 1,
  52460. /** Int */
  52461. Int = 2,
  52462. /** Vector2 */
  52463. Vector2 = 4,
  52464. /** Vector3 */
  52465. Vector3 = 8,
  52466. /** Vector4 */
  52467. Vector4 = 16,
  52468. /** Color3 */
  52469. Color3 = 32,
  52470. /** Color4 */
  52471. Color4 = 64,
  52472. /** Matrix */
  52473. Matrix = 128,
  52474. /** Detect type based on connection */
  52475. AutoDetect = 1024,
  52476. /** Output type that will be defined by input type */
  52477. BasedOnInput = 2048
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /**
  52482. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52483. */
  52484. export enum NodeMaterialBlockConnectionPointMode {
  52485. /** Value is an uniform */
  52486. Uniform = 0,
  52487. /** Value is a mesh attribute */
  52488. Attribute = 1,
  52489. /** Value is a varying between vertex and fragment shaders */
  52490. Varying = 2,
  52491. /** Mode is undefined */
  52492. Undefined = 3
  52493. }
  52494. }
  52495. declare module BABYLON {
  52496. /**
  52497. * Enum used to define system values e.g. values automatically provided by the system
  52498. */
  52499. export enum NodeMaterialSystemValues {
  52500. /** World */
  52501. World = 1,
  52502. /** View */
  52503. View = 2,
  52504. /** Projection */
  52505. Projection = 3,
  52506. /** ViewProjection */
  52507. ViewProjection = 4,
  52508. /** WorldView */
  52509. WorldView = 5,
  52510. /** WorldViewProjection */
  52511. WorldViewProjection = 6,
  52512. /** CameraPosition */
  52513. CameraPosition = 7,
  52514. /** Fog Color */
  52515. FogColor = 8
  52516. }
  52517. }
  52518. declare module BABYLON {
  52519. /**
  52520. * Root class for all node material optimizers
  52521. */
  52522. export class NodeMaterialOptimizer {
  52523. /**
  52524. * Function used to optimize a NodeMaterial graph
  52525. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52526. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52527. */
  52528. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52529. }
  52530. }
  52531. declare module BABYLON {
  52532. /**
  52533. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52534. */
  52535. export class TransformBlock extends NodeMaterialBlock {
  52536. /**
  52537. * Defines the value to use to complement W value to transform it to a Vector4
  52538. */
  52539. complementW: number;
  52540. /**
  52541. * Defines the value to use to complement z value to transform it to a Vector4
  52542. */
  52543. complementZ: number;
  52544. /**
  52545. * Creates a new TransformBlock
  52546. * @param name defines the block name
  52547. */
  52548. constructor(name: string);
  52549. /**
  52550. * Gets the current class name
  52551. * @returns the class name
  52552. */
  52553. getClassName(): string;
  52554. /**
  52555. * Gets the vector input
  52556. */
  52557. readonly vector: NodeMaterialConnectionPoint;
  52558. /**
  52559. * Gets the output component
  52560. */
  52561. readonly output: NodeMaterialConnectionPoint;
  52562. /**
  52563. * Gets the matrix transform input
  52564. */
  52565. readonly transform: NodeMaterialConnectionPoint;
  52566. protected _buildBlock(state: NodeMaterialBuildState): this;
  52567. serialize(): any;
  52568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52569. protected _dumpPropertiesCode(): string;
  52570. }
  52571. }
  52572. declare module BABYLON {
  52573. /**
  52574. * Block used to output the vertex position
  52575. */
  52576. export class VertexOutputBlock extends NodeMaterialBlock {
  52577. /**
  52578. * Creates a new VertexOutputBlock
  52579. * @param name defines the block name
  52580. */
  52581. constructor(name: string);
  52582. /**
  52583. * Gets the current class name
  52584. * @returns the class name
  52585. */
  52586. getClassName(): string;
  52587. /**
  52588. * Gets the vector input component
  52589. */
  52590. readonly vector: NodeMaterialConnectionPoint;
  52591. protected _buildBlock(state: NodeMaterialBuildState): this;
  52592. }
  52593. }
  52594. declare module BABYLON {
  52595. /**
  52596. * Block used to output the final color
  52597. */
  52598. export class FragmentOutputBlock extends NodeMaterialBlock {
  52599. /**
  52600. * Create a new FragmentOutputBlock
  52601. * @param name defines the block name
  52602. */
  52603. constructor(name: string);
  52604. /**
  52605. * Gets the current class name
  52606. * @returns the class name
  52607. */
  52608. getClassName(): string;
  52609. /**
  52610. * Gets the rgba input component
  52611. */
  52612. readonly rgba: NodeMaterialConnectionPoint;
  52613. /**
  52614. * Gets the rgb input component
  52615. */
  52616. readonly rgb: NodeMaterialConnectionPoint;
  52617. /**
  52618. * Gets the a input component
  52619. */
  52620. readonly a: NodeMaterialConnectionPoint;
  52621. protected _buildBlock(state: NodeMaterialBuildState): this;
  52622. }
  52623. }
  52624. declare module BABYLON {
  52625. /**
  52626. * Block used to read a reflection texture from a sampler
  52627. */
  52628. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52629. private _define3DName;
  52630. private _defineCubicName;
  52631. private _defineExplicitName;
  52632. private _defineProjectionName;
  52633. private _defineLocalCubicName;
  52634. private _defineSphericalName;
  52635. private _definePlanarName;
  52636. private _defineEquirectangularName;
  52637. private _defineMirroredEquirectangularFixedName;
  52638. private _defineEquirectangularFixedName;
  52639. private _defineSkyboxName;
  52640. private _cubeSamplerName;
  52641. private _2DSamplerName;
  52642. private _positionUVWName;
  52643. private _directionWName;
  52644. private _reflectionCoordsName;
  52645. private _reflection2DCoordsName;
  52646. private _reflectionColorName;
  52647. private _reflectionMatrixName;
  52648. /**
  52649. * Gets or sets the texture associated with the node
  52650. */
  52651. texture: Nullable<BaseTexture>;
  52652. /**
  52653. * Create a new TextureBlock
  52654. * @param name defines the block name
  52655. */
  52656. constructor(name: string);
  52657. /**
  52658. * Gets the current class name
  52659. * @returns the class name
  52660. */
  52661. getClassName(): string;
  52662. /**
  52663. * Gets the world position input component
  52664. */
  52665. readonly position: NodeMaterialConnectionPoint;
  52666. /**
  52667. * Gets the world position input component
  52668. */
  52669. readonly worldPosition: NodeMaterialConnectionPoint;
  52670. /**
  52671. * Gets the world normal input component
  52672. */
  52673. readonly worldNormal: NodeMaterialConnectionPoint;
  52674. /**
  52675. * Gets the world input component
  52676. */
  52677. readonly world: NodeMaterialConnectionPoint;
  52678. /**
  52679. * Gets the camera (or eye) position component
  52680. */
  52681. readonly cameraPosition: NodeMaterialConnectionPoint;
  52682. /**
  52683. * Gets the view input component
  52684. */
  52685. readonly view: NodeMaterialConnectionPoint;
  52686. /**
  52687. * Gets the rgb output component
  52688. */
  52689. readonly rgb: NodeMaterialConnectionPoint;
  52690. /**
  52691. * Gets the r output component
  52692. */
  52693. readonly r: NodeMaterialConnectionPoint;
  52694. /**
  52695. * Gets the g output component
  52696. */
  52697. readonly g: NodeMaterialConnectionPoint;
  52698. /**
  52699. * Gets the b output component
  52700. */
  52701. readonly b: NodeMaterialConnectionPoint;
  52702. autoConfigure(material: NodeMaterial): void;
  52703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52704. isReady(): boolean;
  52705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52706. private _injectVertexCode;
  52707. private _writeOutput;
  52708. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52709. serialize(): any;
  52710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52711. }
  52712. }
  52713. declare module BABYLON {
  52714. /**
  52715. * Interface used to configure the node material editor
  52716. */
  52717. export interface INodeMaterialEditorOptions {
  52718. /** Define the URl to load node editor script */
  52719. editorURL?: string;
  52720. }
  52721. /** @hidden */
  52722. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52723. /** BONES */
  52724. NUM_BONE_INFLUENCERS: number;
  52725. BonesPerMesh: number;
  52726. BONETEXTURE: boolean;
  52727. /** MORPH TARGETS */
  52728. MORPHTARGETS: boolean;
  52729. MORPHTARGETS_NORMAL: boolean;
  52730. MORPHTARGETS_TANGENT: boolean;
  52731. MORPHTARGETS_UV: boolean;
  52732. NUM_MORPH_INFLUENCERS: number;
  52733. /** IMAGE PROCESSING */
  52734. IMAGEPROCESSING: boolean;
  52735. VIGNETTE: boolean;
  52736. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52737. VIGNETTEBLENDMODEOPAQUE: boolean;
  52738. TONEMAPPING: boolean;
  52739. TONEMAPPING_ACES: boolean;
  52740. CONTRAST: boolean;
  52741. EXPOSURE: boolean;
  52742. COLORCURVES: boolean;
  52743. COLORGRADING: boolean;
  52744. COLORGRADING3D: boolean;
  52745. SAMPLER3DGREENDEPTH: boolean;
  52746. SAMPLER3DBGRMAP: boolean;
  52747. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52748. /** MISC. */
  52749. BUMPDIRECTUV: number;
  52750. constructor();
  52751. setValue(name: string, value: boolean): void;
  52752. }
  52753. /**
  52754. * Class used to configure NodeMaterial
  52755. */
  52756. export interface INodeMaterialOptions {
  52757. /**
  52758. * Defines if blocks should emit comments
  52759. */
  52760. emitComments: boolean;
  52761. }
  52762. /**
  52763. * Class used to create a node based material built by assembling shader blocks
  52764. */
  52765. export class NodeMaterial extends PushMaterial {
  52766. private static _BuildIdGenerator;
  52767. private _options;
  52768. private _vertexCompilationState;
  52769. private _fragmentCompilationState;
  52770. private _sharedData;
  52771. private _buildId;
  52772. private _buildWasSuccessful;
  52773. private _cachedWorldViewMatrix;
  52774. private _cachedWorldViewProjectionMatrix;
  52775. private _optimizers;
  52776. private _animationFrame;
  52777. /** Define the URl to load node editor script */
  52778. static EditorURL: string;
  52779. private BJSNODEMATERIALEDITOR;
  52780. /** Get the inspector from bundle or global */
  52781. private _getGlobalNodeMaterialEditor;
  52782. /**
  52783. * 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)
  52784. */
  52785. ignoreAlpha: boolean;
  52786. /**
  52787. * Defines the maximum number of lights that can be used in the material
  52788. */
  52789. maxSimultaneousLights: number;
  52790. /**
  52791. * Observable raised when the material is built
  52792. */
  52793. onBuildObservable: Observable<NodeMaterial>;
  52794. /**
  52795. * Gets or sets the root nodes of the material vertex shader
  52796. */
  52797. _vertexOutputNodes: NodeMaterialBlock[];
  52798. /**
  52799. * Gets or sets the root nodes of the material fragment (pixel) shader
  52800. */
  52801. _fragmentOutputNodes: NodeMaterialBlock[];
  52802. /** Gets or sets options to control the node material overall behavior */
  52803. options: INodeMaterialOptions;
  52804. /**
  52805. * Default configuration related to image processing available in the standard Material.
  52806. */
  52807. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52808. /**
  52809. * Gets the image processing configuration used either in this material.
  52810. */
  52811. /**
  52812. * Sets the Default image processing configuration used either in the this material.
  52813. *
  52814. * If sets to null, the scene one is in use.
  52815. */
  52816. imageProcessingConfiguration: ImageProcessingConfiguration;
  52817. /**
  52818. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52819. */
  52820. attachedBlocks: NodeMaterialBlock[];
  52821. /**
  52822. * Create a new node based material
  52823. * @param name defines the material name
  52824. * @param scene defines the hosting scene
  52825. * @param options defines creation option
  52826. */
  52827. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52828. /**
  52829. * Gets the current class name of the material e.g. "NodeMaterial"
  52830. * @returns the class name
  52831. */
  52832. getClassName(): string;
  52833. /**
  52834. * Keep track of the image processing observer to allow dispose and replace.
  52835. */
  52836. private _imageProcessingObserver;
  52837. /**
  52838. * Attaches a new image processing configuration to the Standard Material.
  52839. * @param configuration
  52840. */
  52841. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52842. /**
  52843. * Get a block by its name
  52844. * @param name defines the name of the block to retrieve
  52845. * @returns the required block or null if not found
  52846. */
  52847. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52848. /**
  52849. * Get a block by its name
  52850. * @param predicate defines the predicate used to find the good candidate
  52851. * @returns the required block or null if not found
  52852. */
  52853. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52854. /**
  52855. * Get an input block by its name
  52856. * @param predicate defines the predicate used to find the good candidate
  52857. * @returns the required input block or null if not found
  52858. */
  52859. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52860. /**
  52861. * Gets the list of input blocks attached to this material
  52862. * @returns an array of InputBlocks
  52863. */
  52864. getInputBlocks(): InputBlock[];
  52865. /**
  52866. * Adds a new optimizer to the list of optimizers
  52867. * @param optimizer defines the optimizers to add
  52868. * @returns the current material
  52869. */
  52870. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52871. /**
  52872. * Remove an optimizer from the list of optimizers
  52873. * @param optimizer defines the optimizers to remove
  52874. * @returns the current material
  52875. */
  52876. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52877. /**
  52878. * Add a new block to the list of output nodes
  52879. * @param node defines the node to add
  52880. * @returns the current material
  52881. */
  52882. addOutputNode(node: NodeMaterialBlock): this;
  52883. /**
  52884. * Remove a block from the list of root nodes
  52885. * @param node defines the node to remove
  52886. * @returns the current material
  52887. */
  52888. removeOutputNode(node: NodeMaterialBlock): this;
  52889. private _addVertexOutputNode;
  52890. private _removeVertexOutputNode;
  52891. private _addFragmentOutputNode;
  52892. private _removeFragmentOutputNode;
  52893. /**
  52894. * Specifies if the material will require alpha blending
  52895. * @returns a boolean specifying if alpha blending is needed
  52896. */
  52897. needAlphaBlending(): boolean;
  52898. /**
  52899. * Specifies if this material should be rendered in alpha test mode
  52900. * @returns a boolean specifying if an alpha test is needed.
  52901. */
  52902. needAlphaTesting(): boolean;
  52903. private _initializeBlock;
  52904. private _resetDualBlocks;
  52905. /**
  52906. * Build the material and generates the inner effect
  52907. * @param verbose defines if the build should log activity
  52908. */
  52909. build(verbose?: boolean): void;
  52910. /**
  52911. * Runs an otpimization phase to try to improve the shader code
  52912. */
  52913. optimize(): void;
  52914. private _prepareDefinesForAttributes;
  52915. /**
  52916. * Get if the submesh is ready to be used and all its information available.
  52917. * Child classes can use it to update shaders
  52918. * @param mesh defines the mesh to check
  52919. * @param subMesh defines which submesh to check
  52920. * @param useInstances specifies that instances should be used
  52921. * @returns a boolean indicating that the submesh is ready or not
  52922. */
  52923. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52924. /**
  52925. * Get a string representing the shaders built by the current node graph
  52926. */
  52927. readonly compiledShaders: string;
  52928. /**
  52929. * Binds the world matrix to the material
  52930. * @param world defines the world transformation matrix
  52931. */
  52932. bindOnlyWorldMatrix(world: Matrix): void;
  52933. /**
  52934. * Binds the submesh to this material by preparing the effect and shader to draw
  52935. * @param world defines the world transformation matrix
  52936. * @param mesh defines the mesh containing the submesh
  52937. * @param subMesh defines the submesh to bind the material to
  52938. */
  52939. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52940. /**
  52941. * Gets the active textures from the material
  52942. * @returns an array of textures
  52943. */
  52944. getActiveTextures(): BaseTexture[];
  52945. /**
  52946. * Gets the list of texture blocks
  52947. * @returns an array of texture blocks
  52948. */
  52949. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52950. /**
  52951. * Specifies if the material uses a texture
  52952. * @param texture defines the texture to check against the material
  52953. * @returns a boolean specifying if the material uses the texture
  52954. */
  52955. hasTexture(texture: BaseTexture): boolean;
  52956. /**
  52957. * Disposes the material
  52958. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52959. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52960. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52961. */
  52962. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52963. /** Creates the node editor window. */
  52964. private _createNodeEditor;
  52965. /**
  52966. * Launch the node material editor
  52967. * @param config Define the configuration of the editor
  52968. * @return a promise fulfilled when the node editor is visible
  52969. */
  52970. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52971. /**
  52972. * Clear the current material
  52973. */
  52974. clear(): void;
  52975. /**
  52976. * Clear the current material and set it to a default state
  52977. */
  52978. setToDefault(): void;
  52979. /**
  52980. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52981. * @param url defines the url to load from
  52982. * @returns a promise that will fullfil when the material is fully loaded
  52983. */
  52984. loadAsync(url: string): Promise<unknown>;
  52985. private _gatherBlocks;
  52986. /**
  52987. * Generate a string containing the code declaration required to create an equivalent of this material
  52988. * @returns a string
  52989. */
  52990. generateCode(): string;
  52991. /**
  52992. * Serializes this material in a JSON representation
  52993. * @returns the serialized material object
  52994. */
  52995. serialize(): any;
  52996. private _restoreConnections;
  52997. /**
  52998. * Clear the current graph and load a new one from a serialization object
  52999. * @param source defines the JSON representation of the material
  53000. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53001. */
  53002. loadFromSerialization(source: any, rootUrl?: string): void;
  53003. /**
  53004. * Creates a node material from parsed material data
  53005. * @param source defines the JSON representation of the material
  53006. * @param scene defines the hosting scene
  53007. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53008. * @returns a new node material
  53009. */
  53010. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53011. /**
  53012. * Creates a new node material set to default basic configuration
  53013. * @param name defines the name of the material
  53014. * @param scene defines the hosting scene
  53015. * @returns a new NodeMaterial
  53016. */
  53017. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53018. }
  53019. }
  53020. declare module BABYLON {
  53021. /**
  53022. * Block used to read a texture from a sampler
  53023. */
  53024. export class TextureBlock extends NodeMaterialBlock {
  53025. private _defineName;
  53026. private _samplerName;
  53027. private _transformedUVName;
  53028. private _textureTransformName;
  53029. private _textureInfoName;
  53030. private _mainUVName;
  53031. private _mainUVDefineName;
  53032. /**
  53033. * Gets or sets the texture associated with the node
  53034. */
  53035. texture: Nullable<Texture>;
  53036. /**
  53037. * Create a new TextureBlock
  53038. * @param name defines the block name
  53039. */
  53040. constructor(name: string);
  53041. /**
  53042. * Gets the current class name
  53043. * @returns the class name
  53044. */
  53045. getClassName(): string;
  53046. /**
  53047. * Gets the uv input component
  53048. */
  53049. readonly uv: NodeMaterialConnectionPoint;
  53050. /**
  53051. * Gets the rgba output component
  53052. */
  53053. readonly rgba: NodeMaterialConnectionPoint;
  53054. /**
  53055. * Gets the rgb output component
  53056. */
  53057. readonly rgb: NodeMaterialConnectionPoint;
  53058. /**
  53059. * Gets the r output component
  53060. */
  53061. readonly r: NodeMaterialConnectionPoint;
  53062. /**
  53063. * Gets the g output component
  53064. */
  53065. readonly g: NodeMaterialConnectionPoint;
  53066. /**
  53067. * Gets the b output component
  53068. */
  53069. readonly b: NodeMaterialConnectionPoint;
  53070. /**
  53071. * Gets the a output component
  53072. */
  53073. readonly a: NodeMaterialConnectionPoint;
  53074. readonly target: NodeMaterialBlockTargets;
  53075. autoConfigure(material: NodeMaterial): void;
  53076. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53078. isReady(): boolean;
  53079. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53080. private readonly _isMixed;
  53081. private _injectVertexCode;
  53082. private _writeOutput;
  53083. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53084. protected _dumpPropertiesCode(): string;
  53085. serialize(): any;
  53086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53087. }
  53088. }
  53089. declare module BABYLON {
  53090. /**
  53091. * Class used to store shared data between 2 NodeMaterialBuildState
  53092. */
  53093. export class NodeMaterialBuildStateSharedData {
  53094. /**
  53095. * Gets the list of emitted varyings
  53096. */
  53097. temps: string[];
  53098. /**
  53099. * Gets the list of emitted varyings
  53100. */
  53101. varyings: string[];
  53102. /**
  53103. * Gets the varying declaration string
  53104. */
  53105. varyingDeclaration: string;
  53106. /**
  53107. * Input blocks
  53108. */
  53109. inputBlocks: InputBlock[];
  53110. /**
  53111. * Input blocks
  53112. */
  53113. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53114. /**
  53115. * Bindable blocks (Blocks that need to set data to the effect)
  53116. */
  53117. bindableBlocks: NodeMaterialBlock[];
  53118. /**
  53119. * List of blocks that can provide a compilation fallback
  53120. */
  53121. blocksWithFallbacks: NodeMaterialBlock[];
  53122. /**
  53123. * List of blocks that can provide a define update
  53124. */
  53125. blocksWithDefines: NodeMaterialBlock[];
  53126. /**
  53127. * List of blocks that can provide a repeatable content
  53128. */
  53129. repeatableContentBlocks: NodeMaterialBlock[];
  53130. /**
  53131. * List of blocks that can provide a dynamic list of uniforms
  53132. */
  53133. dynamicUniformBlocks: NodeMaterialBlock[];
  53134. /**
  53135. * List of blocks that can block the isReady function for the material
  53136. */
  53137. blockingBlocks: NodeMaterialBlock[];
  53138. /**
  53139. * Gets the list of animated inputs
  53140. */
  53141. animatedInputs: InputBlock[];
  53142. /**
  53143. * Build Id used to avoid multiple recompilations
  53144. */
  53145. buildId: number;
  53146. /** List of emitted variables */
  53147. variableNames: {
  53148. [key: string]: number;
  53149. };
  53150. /** List of emitted defines */
  53151. defineNames: {
  53152. [key: string]: number;
  53153. };
  53154. /** Should emit comments? */
  53155. emitComments: boolean;
  53156. /** Emit build activity */
  53157. verbose: boolean;
  53158. /** Gets or sets the hosting scene */
  53159. scene: Scene;
  53160. /**
  53161. * Gets the compilation hints emitted at compilation time
  53162. */
  53163. hints: {
  53164. needWorldViewMatrix: boolean;
  53165. needWorldViewProjectionMatrix: boolean;
  53166. needAlphaBlending: boolean;
  53167. needAlphaTesting: boolean;
  53168. };
  53169. /**
  53170. * List of compilation checks
  53171. */
  53172. checks: {
  53173. emitVertex: boolean;
  53174. emitFragment: boolean;
  53175. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53176. };
  53177. /** Creates a new shared data */
  53178. constructor();
  53179. /**
  53180. * Emits console errors and exceptions if there is a failing check
  53181. */
  53182. emitErrors(): void;
  53183. }
  53184. }
  53185. declare module BABYLON {
  53186. /**
  53187. * Class used to store node based material build state
  53188. */
  53189. export class NodeMaterialBuildState {
  53190. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53191. supportUniformBuffers: boolean;
  53192. /**
  53193. * Gets the list of emitted attributes
  53194. */
  53195. attributes: string[];
  53196. /**
  53197. * Gets the list of emitted uniforms
  53198. */
  53199. uniforms: string[];
  53200. /**
  53201. * Gets the list of emitted constants
  53202. */
  53203. constants: string[];
  53204. /**
  53205. * Gets the list of emitted uniform buffers
  53206. */
  53207. uniformBuffers: string[];
  53208. /**
  53209. * Gets the list of emitted samplers
  53210. */
  53211. samplers: string[];
  53212. /**
  53213. * Gets the list of emitted functions
  53214. */
  53215. functions: {
  53216. [key: string]: string;
  53217. };
  53218. /**
  53219. * Gets the list of emitted extensions
  53220. */
  53221. extensions: {
  53222. [key: string]: string;
  53223. };
  53224. /**
  53225. * Gets the target of the compilation state
  53226. */
  53227. target: NodeMaterialBlockTargets;
  53228. /**
  53229. * Gets the list of emitted counters
  53230. */
  53231. counters: {
  53232. [key: string]: number;
  53233. };
  53234. /**
  53235. * Shared data between multiple NodeMaterialBuildState instances
  53236. */
  53237. sharedData: NodeMaterialBuildStateSharedData;
  53238. /** @hidden */
  53239. _vertexState: NodeMaterialBuildState;
  53240. /** @hidden */
  53241. _attributeDeclaration: string;
  53242. /** @hidden */
  53243. _uniformDeclaration: string;
  53244. /** @hidden */
  53245. _constantDeclaration: string;
  53246. /** @hidden */
  53247. _samplerDeclaration: string;
  53248. /** @hidden */
  53249. _varyingTransfer: string;
  53250. private _repeatableContentAnchorIndex;
  53251. /** @hidden */
  53252. _builtCompilationString: string;
  53253. /**
  53254. * Gets the emitted compilation strings
  53255. */
  53256. compilationString: string;
  53257. /**
  53258. * Finalize the compilation strings
  53259. * @param state defines the current compilation state
  53260. */
  53261. finalize(state: NodeMaterialBuildState): void;
  53262. /** @hidden */
  53263. readonly _repeatableContentAnchor: string;
  53264. /** @hidden */
  53265. _getFreeVariableName(prefix: string): string;
  53266. /** @hidden */
  53267. _getFreeDefineName(prefix: string): string;
  53268. /** @hidden */
  53269. _excludeVariableName(name: string): void;
  53270. /** @hidden */
  53271. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53272. /** @hidden */
  53273. _emitExtension(name: string, extension: string): void;
  53274. /** @hidden */
  53275. _emitFunction(name: string, code: string, comments: string): void;
  53276. /** @hidden */
  53277. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53278. replaceStrings?: {
  53279. search: RegExp;
  53280. replace: string;
  53281. }[];
  53282. repeatKey?: string;
  53283. }): string;
  53284. /** @hidden */
  53285. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53286. repeatKey?: string;
  53287. removeAttributes?: boolean;
  53288. removeUniforms?: boolean;
  53289. removeVaryings?: boolean;
  53290. removeIfDef?: boolean;
  53291. replaceStrings?: {
  53292. search: RegExp;
  53293. replace: string;
  53294. }[];
  53295. }, storeKey?: string): void;
  53296. /** @hidden */
  53297. _registerTempVariable(name: string): boolean;
  53298. /** @hidden */
  53299. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53300. /** @hidden */
  53301. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53302. }
  53303. }
  53304. declare module BABYLON {
  53305. /**
  53306. * Defines a block that can be used inside a node based material
  53307. */
  53308. export class NodeMaterialBlock {
  53309. private _buildId;
  53310. private _buildTarget;
  53311. private _target;
  53312. private _isFinalMerger;
  53313. private _isInput;
  53314. /** @hidden */
  53315. _codeVariableName: string;
  53316. /** @hidden */
  53317. _inputs: NodeMaterialConnectionPoint[];
  53318. /** @hidden */
  53319. _outputs: NodeMaterialConnectionPoint[];
  53320. /** @hidden */
  53321. _preparationId: number;
  53322. /**
  53323. * Gets or sets the name of the block
  53324. */
  53325. name: string;
  53326. /**
  53327. * Gets or sets the unique id of the node
  53328. */
  53329. uniqueId: number;
  53330. /**
  53331. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53332. */
  53333. readonly isFinalMerger: boolean;
  53334. /**
  53335. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53336. */
  53337. readonly isInput: boolean;
  53338. /**
  53339. * Gets or sets the build Id
  53340. */
  53341. buildId: number;
  53342. /**
  53343. * Gets or sets the target of the block
  53344. */
  53345. target: NodeMaterialBlockTargets;
  53346. /**
  53347. * Gets the list of input points
  53348. */
  53349. readonly inputs: NodeMaterialConnectionPoint[];
  53350. /** Gets the list of output points */
  53351. readonly outputs: NodeMaterialConnectionPoint[];
  53352. /**
  53353. * Find an input by its name
  53354. * @param name defines the name of the input to look for
  53355. * @returns the input or null if not found
  53356. */
  53357. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53358. /**
  53359. * Find an output by its name
  53360. * @param name defines the name of the outputto look for
  53361. * @returns the output or null if not found
  53362. */
  53363. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53364. /**
  53365. * Creates a new NodeMaterialBlock
  53366. * @param name defines the block name
  53367. * @param target defines the target of that block (Vertex by default)
  53368. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53369. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53370. */
  53371. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53372. /**
  53373. * Initialize the block and prepare the context for build
  53374. * @param state defines the state that will be used for the build
  53375. */
  53376. initialize(state: NodeMaterialBuildState): void;
  53377. /**
  53378. * Bind data to effect. Will only be called for blocks with isBindable === true
  53379. * @param effect defines the effect to bind data to
  53380. * @param nodeMaterial defines the hosting NodeMaterial
  53381. * @param mesh defines the mesh that will be rendered
  53382. */
  53383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53384. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53385. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53386. protected _writeFloat(value: number): string;
  53387. /**
  53388. * Gets the current class name e.g. "NodeMaterialBlock"
  53389. * @returns the class name
  53390. */
  53391. getClassName(): string;
  53392. /**
  53393. * Register a new input. Must be called inside a block constructor
  53394. * @param name defines the connection point name
  53395. * @param type defines the connection point type
  53396. * @param isOptional defines a boolean indicating that this input can be omitted
  53397. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53398. * @returns the current block
  53399. */
  53400. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53401. /**
  53402. * Register a new output. Must be called inside a block constructor
  53403. * @param name defines the connection point name
  53404. * @param type defines the connection point type
  53405. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53406. * @returns the current block
  53407. */
  53408. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53409. /**
  53410. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53411. * @param forOutput defines an optional connection point to check compatibility with
  53412. * @returns the first available input or null
  53413. */
  53414. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53415. /**
  53416. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53417. * @param forBlock defines an optional block to check compatibility with
  53418. * @returns the first available input or null
  53419. */
  53420. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53421. /**
  53422. * Gets the sibling of the given output
  53423. * @param current defines the current output
  53424. * @returns the next output in the list or null
  53425. */
  53426. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53427. /**
  53428. * Connect current block with another block
  53429. * @param other defines the block to connect with
  53430. * @param options define the various options to help pick the right connections
  53431. * @returns the current block
  53432. */
  53433. connectTo(other: NodeMaterialBlock, options?: {
  53434. input?: string;
  53435. output?: string;
  53436. outputSwizzle?: string;
  53437. }): this | undefined;
  53438. protected _buildBlock(state: NodeMaterialBuildState): void;
  53439. /**
  53440. * Add uniforms, samplers and uniform buffers at compilation time
  53441. * @param state defines the state to update
  53442. * @param nodeMaterial defines the node material requesting the update
  53443. * @param defines defines the material defines to update
  53444. */
  53445. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53446. /**
  53447. * Add potential fallbacks if shader compilation fails
  53448. * @param mesh defines the mesh to be rendered
  53449. * @param fallbacks defines the current prioritized list of fallbacks
  53450. */
  53451. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53452. /**
  53453. * Initialize defines for shader compilation
  53454. * @param mesh defines the mesh to be rendered
  53455. * @param nodeMaterial defines the node material requesting the update
  53456. * @param defines defines the material defines to update
  53457. * @param useInstances specifies that instances should be used
  53458. */
  53459. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53460. /**
  53461. * Update defines for shader compilation
  53462. * @param mesh defines the mesh to be rendered
  53463. * @param nodeMaterial defines the node material requesting the update
  53464. * @param defines defines the material defines to update
  53465. * @param useInstances specifies that instances should be used
  53466. */
  53467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53468. /**
  53469. * Lets the block try to connect some inputs automatically
  53470. * @param material defines the hosting NodeMaterial
  53471. */
  53472. autoConfigure(material: NodeMaterial): void;
  53473. /**
  53474. * Function called when a block is declared as repeatable content generator
  53475. * @param vertexShaderState defines the current compilation state for the vertex shader
  53476. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53477. * @param mesh defines the mesh to be rendered
  53478. * @param defines defines the material defines to update
  53479. */
  53480. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53481. /**
  53482. * Checks if the block is ready
  53483. * @param mesh defines the mesh to be rendered
  53484. * @param nodeMaterial defines the node material requesting the update
  53485. * @param defines defines the material defines to update
  53486. * @param useInstances specifies that instances should be used
  53487. * @returns true if the block is ready
  53488. */
  53489. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53490. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53491. private _processBuild;
  53492. /**
  53493. * Compile the current node and generate the shader code
  53494. * @param state defines the current compilation state (uniforms, samplers, current string)
  53495. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53496. * @returns true if already built
  53497. */
  53498. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53499. protected _inputRename(name: string): string;
  53500. protected _outputRename(name: string): string;
  53501. protected _dumpPropertiesCode(): string;
  53502. /** @hidden */
  53503. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53504. /**
  53505. * Clone the current block to a new identical block
  53506. * @param scene defines the hosting scene
  53507. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53508. * @returns a copy of the current block
  53509. */
  53510. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53511. /**
  53512. * Serializes this block in a JSON representation
  53513. * @returns the serialized block object
  53514. */
  53515. serialize(): any;
  53516. /** @hidden */
  53517. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53518. }
  53519. }
  53520. declare module BABYLON {
  53521. /**
  53522. * Enum defining the type of animations supported by InputBlock
  53523. */
  53524. export enum AnimatedInputBlockTypes {
  53525. /** No animation */
  53526. None = 0,
  53527. /** Time based animation. Will only work for floats */
  53528. Time = 1
  53529. }
  53530. }
  53531. declare module BABYLON {
  53532. /**
  53533. * Block used to expose an input value
  53534. */
  53535. export class InputBlock extends NodeMaterialBlock {
  53536. private _mode;
  53537. private _associatedVariableName;
  53538. private _storedValue;
  53539. private _valueCallback;
  53540. private _type;
  53541. private _animationType;
  53542. /** Gets or set a value used to limit the range of float values */
  53543. min: number;
  53544. /** Gets or set a value used to limit the range of float values */
  53545. max: number;
  53546. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53547. matrixMode: number;
  53548. /** @hidden */
  53549. _systemValue: Nullable<NodeMaterialSystemValues>;
  53550. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53551. visibleInInspector: boolean;
  53552. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53553. isConstant: boolean;
  53554. /**
  53555. * Gets or sets the connection point type (default is float)
  53556. */
  53557. readonly type: NodeMaterialBlockConnectionPointTypes;
  53558. /**
  53559. * Creates a new InputBlock
  53560. * @param name defines the block name
  53561. * @param target defines the target of that block (Vertex by default)
  53562. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53563. */
  53564. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53565. /**
  53566. * Gets the output component
  53567. */
  53568. readonly output: NodeMaterialConnectionPoint;
  53569. /**
  53570. * Set the source of this connection point to a vertex attribute
  53571. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53572. * @returns the current connection point
  53573. */
  53574. setAsAttribute(attributeName?: string): InputBlock;
  53575. /**
  53576. * Set the source of this connection point to a system value
  53577. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53578. * @returns the current connection point
  53579. */
  53580. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53581. /**
  53582. * Gets or sets the value of that point.
  53583. * Please note that this value will be ignored if valueCallback is defined
  53584. */
  53585. value: any;
  53586. /**
  53587. * Gets or sets a callback used to get the value of that point.
  53588. * Please note that setting this value will force the connection point to ignore the value property
  53589. */
  53590. valueCallback: () => any;
  53591. /**
  53592. * Gets or sets the associated variable name in the shader
  53593. */
  53594. associatedVariableName: string;
  53595. /** Gets or sets the type of animation applied to the input */
  53596. animationType: AnimatedInputBlockTypes;
  53597. /**
  53598. * Gets a boolean indicating that this connection point not defined yet
  53599. */
  53600. readonly isUndefined: boolean;
  53601. /**
  53602. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53603. * In this case the connection point name must be the name of the uniform to use.
  53604. * Can only be set on inputs
  53605. */
  53606. isUniform: boolean;
  53607. /**
  53608. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53609. * In this case the connection point name must be the name of the attribute to use
  53610. * Can only be set on inputs
  53611. */
  53612. isAttribute: boolean;
  53613. /**
  53614. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53615. * Can only be set on exit points
  53616. */
  53617. isVarying: boolean;
  53618. /**
  53619. * Gets a boolean indicating that the current connection point is a system value
  53620. */
  53621. readonly isSystemValue: boolean;
  53622. /**
  53623. * Gets or sets the current well known value or null if not defined as a system value
  53624. */
  53625. systemValue: Nullable<NodeMaterialSystemValues>;
  53626. /**
  53627. * Gets the current class name
  53628. * @returns the class name
  53629. */
  53630. getClassName(): string;
  53631. /**
  53632. * Animate the input if animationType !== None
  53633. * @param scene defines the rendering scene
  53634. */
  53635. animate(scene: Scene): void;
  53636. private _emitDefine;
  53637. initialize(state: NodeMaterialBuildState): void;
  53638. /**
  53639. * Set the input block to its default value (based on its type)
  53640. */
  53641. setDefaultValue(): void;
  53642. private _emitConstant;
  53643. private _emit;
  53644. /** @hidden */
  53645. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53646. /** @hidden */
  53647. _transmit(effect: Effect, scene: Scene): void;
  53648. protected _buildBlock(state: NodeMaterialBuildState): void;
  53649. protected _dumpPropertiesCode(): string;
  53650. serialize(): any;
  53651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53652. }
  53653. }
  53654. declare module BABYLON {
  53655. /**
  53656. * Defines a connection point for a block
  53657. */
  53658. export class NodeMaterialConnectionPoint {
  53659. /** @hidden */
  53660. _ownerBlock: NodeMaterialBlock;
  53661. /** @hidden */
  53662. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53663. private _endpoints;
  53664. private _associatedVariableName;
  53665. /** @hidden */
  53666. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53667. /** @hidden */
  53668. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53669. private _type;
  53670. /** @hidden */
  53671. _enforceAssociatedVariableName: boolean;
  53672. /**
  53673. * Gets or sets the additional types supported by this connection point
  53674. */
  53675. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53676. /**
  53677. * Gets or sets the additional types excluded by this connection point
  53678. */
  53679. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53680. /**
  53681. * Gets or sets the associated variable name in the shader
  53682. */
  53683. associatedVariableName: string;
  53684. /**
  53685. * Gets or sets the connection point type (default is float)
  53686. */
  53687. type: NodeMaterialBlockConnectionPointTypes;
  53688. /**
  53689. * Gets or sets the connection point name
  53690. */
  53691. name: string;
  53692. /**
  53693. * Gets or sets a boolean indicating that this connection point can be omitted
  53694. */
  53695. isOptional: boolean;
  53696. /**
  53697. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53698. */
  53699. define: string;
  53700. /** Gets or sets the target of that connection point */
  53701. target: NodeMaterialBlockTargets;
  53702. /**
  53703. * Gets a boolean indicating that the current point is connected
  53704. */
  53705. readonly isConnected: boolean;
  53706. /**
  53707. * Gets a boolean indicating that the current point is connected to an input block
  53708. */
  53709. readonly isConnectedToInputBlock: boolean;
  53710. /**
  53711. * Gets a the connected input block (if any)
  53712. */
  53713. readonly connectInputBlock: Nullable<InputBlock>;
  53714. /** Get the other side of the connection (if any) */
  53715. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53716. /** Get the block that owns this connection point */
  53717. readonly ownerBlock: NodeMaterialBlock;
  53718. /** Get the block connected on the other side of this connection (if any) */
  53719. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53720. /** Get the block connected on the endpoints of this connection (if any) */
  53721. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53722. /** Gets the list of connected endpoints */
  53723. readonly endpoints: NodeMaterialConnectionPoint[];
  53724. /** Gets a boolean indicating if that output point is connected to at least one input */
  53725. readonly hasEndpoints: boolean;
  53726. /**
  53727. * Creates a new connection point
  53728. * @param name defines the connection point name
  53729. * @param ownerBlock defines the block hosting this connection point
  53730. */
  53731. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53732. /**
  53733. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53734. * @returns the class name
  53735. */
  53736. getClassName(): string;
  53737. /**
  53738. * Gets an boolean indicating if the current point can be connected to another point
  53739. * @param connectionPoint defines the other connection point
  53740. * @returns true if the connection is possible
  53741. */
  53742. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53743. /**
  53744. * Connect this point to another connection point
  53745. * @param connectionPoint defines the other connection point
  53746. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53747. * @returns the current connection point
  53748. */
  53749. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53750. /**
  53751. * Disconnect this point from one of his endpoint
  53752. * @param endpoint defines the other connection point
  53753. * @returns the current connection point
  53754. */
  53755. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53756. /**
  53757. * Serializes this point in a JSON representation
  53758. * @returns the serialized point object
  53759. */
  53760. serialize(): any;
  53761. }
  53762. }
  53763. declare module BABYLON {
  53764. /**
  53765. * Block used to add support for vertex skinning (bones)
  53766. */
  53767. export class BonesBlock extends NodeMaterialBlock {
  53768. /**
  53769. * Creates a new BonesBlock
  53770. * @param name defines the block name
  53771. */
  53772. constructor(name: string);
  53773. /**
  53774. * Initialize the block and prepare the context for build
  53775. * @param state defines the state that will be used for the build
  53776. */
  53777. initialize(state: NodeMaterialBuildState): void;
  53778. /**
  53779. * Gets the current class name
  53780. * @returns the class name
  53781. */
  53782. getClassName(): string;
  53783. /**
  53784. * Gets the matrix indices input component
  53785. */
  53786. readonly matricesIndices: NodeMaterialConnectionPoint;
  53787. /**
  53788. * Gets the matrix weights input component
  53789. */
  53790. readonly matricesWeights: NodeMaterialConnectionPoint;
  53791. /**
  53792. * Gets the extra matrix indices input component
  53793. */
  53794. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53795. /**
  53796. * Gets the extra matrix weights input component
  53797. */
  53798. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53799. /**
  53800. * Gets the world input component
  53801. */
  53802. readonly world: NodeMaterialConnectionPoint;
  53803. /**
  53804. * Gets the output component
  53805. */
  53806. readonly output: NodeMaterialConnectionPoint;
  53807. autoConfigure(material: NodeMaterial): void;
  53808. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53809. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53810. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53811. protected _buildBlock(state: NodeMaterialBuildState): this;
  53812. }
  53813. }
  53814. declare module BABYLON {
  53815. /**
  53816. * Block used to add support for instances
  53817. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53818. */
  53819. export class InstancesBlock extends NodeMaterialBlock {
  53820. /**
  53821. * Creates a new InstancesBlock
  53822. * @param name defines the block name
  53823. */
  53824. constructor(name: string);
  53825. /**
  53826. * Gets the current class name
  53827. * @returns the class name
  53828. */
  53829. getClassName(): string;
  53830. /**
  53831. * Gets the first world row input component
  53832. */
  53833. readonly world0: NodeMaterialConnectionPoint;
  53834. /**
  53835. * Gets the second world row input component
  53836. */
  53837. readonly world1: NodeMaterialConnectionPoint;
  53838. /**
  53839. * Gets the third world row input component
  53840. */
  53841. readonly world2: NodeMaterialConnectionPoint;
  53842. /**
  53843. * Gets the forth world row input component
  53844. */
  53845. readonly world3: NodeMaterialConnectionPoint;
  53846. /**
  53847. * Gets the world input component
  53848. */
  53849. readonly world: NodeMaterialConnectionPoint;
  53850. /**
  53851. * Gets the output component
  53852. */
  53853. readonly output: NodeMaterialConnectionPoint;
  53854. autoConfigure(material: NodeMaterial): void;
  53855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53856. protected _buildBlock(state: NodeMaterialBuildState): this;
  53857. }
  53858. }
  53859. declare module BABYLON {
  53860. /**
  53861. * Block used to add morph targets support to vertex shader
  53862. */
  53863. export class MorphTargetsBlock extends NodeMaterialBlock {
  53864. private _repeatableContentAnchor;
  53865. private _repeatebleContentGenerated;
  53866. /**
  53867. * Create a new MorphTargetsBlock
  53868. * @param name defines the block name
  53869. */
  53870. constructor(name: string);
  53871. /**
  53872. * Gets the current class name
  53873. * @returns the class name
  53874. */
  53875. getClassName(): string;
  53876. /**
  53877. * Gets the position input component
  53878. */
  53879. readonly position: NodeMaterialConnectionPoint;
  53880. /**
  53881. * Gets the normal input component
  53882. */
  53883. readonly normal: NodeMaterialConnectionPoint;
  53884. /**
  53885. * Gets the tangent input component
  53886. */
  53887. readonly tangent: NodeMaterialConnectionPoint;
  53888. /**
  53889. * Gets the tangent input component
  53890. */
  53891. readonly uv: NodeMaterialConnectionPoint;
  53892. /**
  53893. * Gets the position output component
  53894. */
  53895. readonly positionOutput: NodeMaterialConnectionPoint;
  53896. /**
  53897. * Gets the normal output component
  53898. */
  53899. readonly normalOutput: NodeMaterialConnectionPoint;
  53900. /**
  53901. * Gets the tangent output component
  53902. */
  53903. readonly tangentOutput: NodeMaterialConnectionPoint;
  53904. /**
  53905. * Gets the tangent output component
  53906. */
  53907. readonly uvOutput: NodeMaterialConnectionPoint;
  53908. initialize(state: NodeMaterialBuildState): void;
  53909. autoConfigure(material: NodeMaterial): void;
  53910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53911. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53912. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53913. protected _buildBlock(state: NodeMaterialBuildState): this;
  53914. }
  53915. }
  53916. declare module BABYLON {
  53917. /**
  53918. * Block used to get data information from a light
  53919. */
  53920. export class LightInformationBlock extends NodeMaterialBlock {
  53921. private _lightDataUniformName;
  53922. private _lightColorUniformName;
  53923. private _lightTypeDefineName;
  53924. /**
  53925. * Gets or sets the light associated with this block
  53926. */
  53927. light: Nullable<Light>;
  53928. /**
  53929. * Creates a new LightInformationBlock
  53930. * @param name defines the block name
  53931. */
  53932. constructor(name: string);
  53933. /**
  53934. * Gets the current class name
  53935. * @returns the class name
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Gets the world position input component
  53940. */
  53941. readonly worldPosition: NodeMaterialConnectionPoint;
  53942. /**
  53943. * Gets the direction output component
  53944. */
  53945. readonly direction: NodeMaterialConnectionPoint;
  53946. /**
  53947. * Gets the direction output component
  53948. */
  53949. readonly color: NodeMaterialConnectionPoint;
  53950. /**
  53951. * Gets the direction output component
  53952. */
  53953. readonly intensity: NodeMaterialConnectionPoint;
  53954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53956. protected _buildBlock(state: NodeMaterialBuildState): this;
  53957. serialize(): any;
  53958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53959. }
  53960. }
  53961. declare module BABYLON {
  53962. /**
  53963. * Block used to add image processing support to fragment shader
  53964. */
  53965. export class ImageProcessingBlock extends NodeMaterialBlock {
  53966. /**
  53967. * Create a new ImageProcessingBlock
  53968. * @param name defines the block name
  53969. */
  53970. constructor(name: string);
  53971. /**
  53972. * Gets the current class name
  53973. * @returns the class name
  53974. */
  53975. getClassName(): string;
  53976. /**
  53977. * Gets the color input component
  53978. */
  53979. readonly color: NodeMaterialConnectionPoint;
  53980. /**
  53981. * Gets the output component
  53982. */
  53983. readonly output: NodeMaterialConnectionPoint;
  53984. /**
  53985. * Initialize the block and prepare the context for build
  53986. * @param state defines the state that will be used for the build
  53987. */
  53988. initialize(state: NodeMaterialBuildState): void;
  53989. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53991. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53992. protected _buildBlock(state: NodeMaterialBuildState): this;
  53993. }
  53994. }
  53995. declare module BABYLON {
  53996. /**
  53997. * Block used to pertub normals based on a normal map
  53998. */
  53999. export class PerturbNormalBlock extends NodeMaterialBlock {
  54000. private _tangentSpaceParameterName;
  54001. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54002. invertX: boolean;
  54003. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54004. invertY: boolean;
  54005. /**
  54006. * Create a new PerturbNormalBlock
  54007. * @param name defines the block name
  54008. */
  54009. constructor(name: string);
  54010. /**
  54011. * Gets the current class name
  54012. * @returns the class name
  54013. */
  54014. getClassName(): string;
  54015. /**
  54016. * Gets the world position input component
  54017. */
  54018. readonly worldPosition: NodeMaterialConnectionPoint;
  54019. /**
  54020. * Gets the world normal input component
  54021. */
  54022. readonly worldNormal: NodeMaterialConnectionPoint;
  54023. /**
  54024. * Gets the uv input component
  54025. */
  54026. readonly uv: NodeMaterialConnectionPoint;
  54027. /**
  54028. * Gets the normal map color input component
  54029. */
  54030. readonly normalMapColor: NodeMaterialConnectionPoint;
  54031. /**
  54032. * Gets the strength input component
  54033. */
  54034. readonly strength: NodeMaterialConnectionPoint;
  54035. /**
  54036. * Gets the output component
  54037. */
  54038. readonly output: NodeMaterialConnectionPoint;
  54039. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54041. autoConfigure(material: NodeMaterial): void;
  54042. protected _buildBlock(state: NodeMaterialBuildState): this;
  54043. protected _dumpPropertiesCode(): string;
  54044. serialize(): any;
  54045. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54046. }
  54047. }
  54048. declare module BABYLON {
  54049. /**
  54050. * Block used to discard a pixel if a value is smaller than a cutoff
  54051. */
  54052. export class DiscardBlock extends NodeMaterialBlock {
  54053. /**
  54054. * Create a new DiscardBlock
  54055. * @param name defines the block name
  54056. */
  54057. constructor(name: string);
  54058. /**
  54059. * Gets the current class name
  54060. * @returns the class name
  54061. */
  54062. getClassName(): string;
  54063. /**
  54064. * Gets the color input component
  54065. */
  54066. readonly value: NodeMaterialConnectionPoint;
  54067. /**
  54068. * Gets the cutoff input component
  54069. */
  54070. readonly cutoff: NodeMaterialConnectionPoint;
  54071. protected _buildBlock(state: NodeMaterialBuildState): this;
  54072. }
  54073. }
  54074. declare module BABYLON {
  54075. /**
  54076. * Block used to add support for scene fog
  54077. */
  54078. export class FogBlock extends NodeMaterialBlock {
  54079. private _fogDistanceName;
  54080. private _fogParameters;
  54081. /**
  54082. * Create a new FogBlock
  54083. * @param name defines the block name
  54084. */
  54085. constructor(name: string);
  54086. /**
  54087. * Gets the current class name
  54088. * @returns the class name
  54089. */
  54090. getClassName(): string;
  54091. /**
  54092. * Gets the world position input component
  54093. */
  54094. readonly worldPosition: NodeMaterialConnectionPoint;
  54095. /**
  54096. * Gets the view input component
  54097. */
  54098. readonly view: NodeMaterialConnectionPoint;
  54099. /**
  54100. * Gets the color input component
  54101. */
  54102. readonly input: NodeMaterialConnectionPoint;
  54103. /**
  54104. * Gets the fog color input component
  54105. */
  54106. readonly fogColor: NodeMaterialConnectionPoint;
  54107. /**
  54108. * Gets the output component
  54109. */
  54110. readonly output: NodeMaterialConnectionPoint;
  54111. autoConfigure(material: NodeMaterial): void;
  54112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54114. protected _buildBlock(state: NodeMaterialBuildState): this;
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /**
  54119. * Block used to add light in the fragment shader
  54120. */
  54121. export class LightBlock extends NodeMaterialBlock {
  54122. private _lightId;
  54123. /**
  54124. * Gets or sets the light associated with this block
  54125. */
  54126. light: Nullable<Light>;
  54127. /**
  54128. * Create a new LightBlock
  54129. * @param name defines the block name
  54130. */
  54131. constructor(name: string);
  54132. /**
  54133. * Gets the current class name
  54134. * @returns the class name
  54135. */
  54136. getClassName(): string;
  54137. /**
  54138. * Gets the world position input component
  54139. */
  54140. readonly worldPosition: NodeMaterialConnectionPoint;
  54141. /**
  54142. * Gets the world normal input component
  54143. */
  54144. readonly worldNormal: NodeMaterialConnectionPoint;
  54145. /**
  54146. * Gets the camera (or eye) position component
  54147. */
  54148. readonly cameraPosition: NodeMaterialConnectionPoint;
  54149. /**
  54150. * Gets the diffuse output component
  54151. */
  54152. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54153. /**
  54154. * Gets the specular output component
  54155. */
  54156. readonly specularOutput: NodeMaterialConnectionPoint;
  54157. autoConfigure(material: NodeMaterial): void;
  54158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54159. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54161. private _injectVertexCode;
  54162. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54163. serialize(): any;
  54164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54165. }
  54166. }
  54167. declare module BABYLON {
  54168. /**
  54169. * Block used to multiply 2 values
  54170. */
  54171. export class MultiplyBlock extends NodeMaterialBlock {
  54172. /**
  54173. * Creates a new MultiplyBlock
  54174. * @param name defines the block name
  54175. */
  54176. constructor(name: string);
  54177. /**
  54178. * Gets the current class name
  54179. * @returns the class name
  54180. */
  54181. getClassName(): string;
  54182. /**
  54183. * Gets the left operand input component
  54184. */
  54185. readonly left: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Gets the right operand input component
  54188. */
  54189. readonly right: NodeMaterialConnectionPoint;
  54190. /**
  54191. * Gets the output component
  54192. */
  54193. readonly output: NodeMaterialConnectionPoint;
  54194. protected _buildBlock(state: NodeMaterialBuildState): this;
  54195. }
  54196. }
  54197. declare module BABYLON {
  54198. /**
  54199. * Block used to add 2 vectors
  54200. */
  54201. export class AddBlock extends NodeMaterialBlock {
  54202. /**
  54203. * Creates a new AddBlock
  54204. * @param name defines the block name
  54205. */
  54206. constructor(name: string);
  54207. /**
  54208. * Gets the current class name
  54209. * @returns the class name
  54210. */
  54211. getClassName(): string;
  54212. /**
  54213. * Gets the left operand input component
  54214. */
  54215. readonly left: NodeMaterialConnectionPoint;
  54216. /**
  54217. * Gets the right operand input component
  54218. */
  54219. readonly right: NodeMaterialConnectionPoint;
  54220. /**
  54221. * Gets the output component
  54222. */
  54223. readonly output: NodeMaterialConnectionPoint;
  54224. protected _buildBlock(state: NodeMaterialBuildState): this;
  54225. }
  54226. }
  54227. declare module BABYLON {
  54228. /**
  54229. * Block used to scale a vector by a float
  54230. */
  54231. export class ScaleBlock extends NodeMaterialBlock {
  54232. /**
  54233. * Creates a new ScaleBlock
  54234. * @param name defines the block name
  54235. */
  54236. constructor(name: string);
  54237. /**
  54238. * Gets the current class name
  54239. * @returns the class name
  54240. */
  54241. getClassName(): string;
  54242. /**
  54243. * Gets the input component
  54244. */
  54245. readonly input: NodeMaterialConnectionPoint;
  54246. /**
  54247. * Gets the factor input component
  54248. */
  54249. readonly factor: NodeMaterialConnectionPoint;
  54250. /**
  54251. * Gets the output component
  54252. */
  54253. readonly output: NodeMaterialConnectionPoint;
  54254. protected _buildBlock(state: NodeMaterialBuildState): this;
  54255. }
  54256. }
  54257. declare module BABYLON {
  54258. /**
  54259. * Block used to clamp a float
  54260. */
  54261. export class ClampBlock extends NodeMaterialBlock {
  54262. /** Gets or sets the minimum range */
  54263. minimum: number;
  54264. /** Gets or sets the maximum range */
  54265. maximum: number;
  54266. /**
  54267. * Creates a new ClampBlock
  54268. * @param name defines the block name
  54269. */
  54270. constructor(name: string);
  54271. /**
  54272. * Gets the current class name
  54273. * @returns the class name
  54274. */
  54275. getClassName(): string;
  54276. /**
  54277. * Gets the value input component
  54278. */
  54279. readonly value: NodeMaterialConnectionPoint;
  54280. /**
  54281. * Gets the output component
  54282. */
  54283. readonly output: NodeMaterialConnectionPoint;
  54284. protected _buildBlock(state: NodeMaterialBuildState): this;
  54285. protected _dumpPropertiesCode(): string;
  54286. serialize(): any;
  54287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54288. }
  54289. }
  54290. declare module BABYLON {
  54291. /**
  54292. * Block used to apply a cross product between 2 vectors
  54293. */
  54294. export class CrossBlock extends NodeMaterialBlock {
  54295. /**
  54296. * Creates a new CrossBlock
  54297. * @param name defines the block name
  54298. */
  54299. constructor(name: string);
  54300. /**
  54301. * Gets the current class name
  54302. * @returns the class name
  54303. */
  54304. getClassName(): string;
  54305. /**
  54306. * Gets the left operand input component
  54307. */
  54308. readonly left: NodeMaterialConnectionPoint;
  54309. /**
  54310. * Gets the right operand input component
  54311. */
  54312. readonly right: NodeMaterialConnectionPoint;
  54313. /**
  54314. * Gets the output component
  54315. */
  54316. readonly output: NodeMaterialConnectionPoint;
  54317. protected _buildBlock(state: NodeMaterialBuildState): this;
  54318. }
  54319. }
  54320. declare module BABYLON {
  54321. /**
  54322. * Block used to apply a dot product between 2 vectors
  54323. */
  54324. export class DotBlock extends NodeMaterialBlock {
  54325. /**
  54326. * Creates a new DotBlock
  54327. * @param name defines the block name
  54328. */
  54329. constructor(name: string);
  54330. /**
  54331. * Gets the current class name
  54332. * @returns the class name
  54333. */
  54334. getClassName(): string;
  54335. /**
  54336. * Gets the left operand input component
  54337. */
  54338. readonly left: NodeMaterialConnectionPoint;
  54339. /**
  54340. * Gets the right operand input component
  54341. */
  54342. readonly right: NodeMaterialConnectionPoint;
  54343. /**
  54344. * Gets the output component
  54345. */
  54346. readonly output: NodeMaterialConnectionPoint;
  54347. protected _buildBlock(state: NodeMaterialBuildState): this;
  54348. }
  54349. }
  54350. declare module BABYLON {
  54351. /**
  54352. * Block used to remap a float from a range to a new one
  54353. */
  54354. export class RemapBlock extends NodeMaterialBlock {
  54355. /**
  54356. * Gets or sets the source range
  54357. */
  54358. sourceRange: Vector2;
  54359. /**
  54360. * Gets or sets the target range
  54361. */
  54362. targetRange: Vector2;
  54363. /**
  54364. * Creates a new RemapBlock
  54365. * @param name defines the block name
  54366. */
  54367. constructor(name: string);
  54368. /**
  54369. * Gets the current class name
  54370. * @returns the class name
  54371. */
  54372. getClassName(): string;
  54373. /**
  54374. * Gets the input component
  54375. */
  54376. readonly input: NodeMaterialConnectionPoint;
  54377. /**
  54378. * Gets the source min input component
  54379. */
  54380. readonly sourceMin: NodeMaterialConnectionPoint;
  54381. /**
  54382. * Gets the source max input component
  54383. */
  54384. readonly sourceMax: NodeMaterialConnectionPoint;
  54385. /**
  54386. * Gets the target min input component
  54387. */
  54388. readonly targetMin: NodeMaterialConnectionPoint;
  54389. /**
  54390. * Gets the target max input component
  54391. */
  54392. readonly targetMax: NodeMaterialConnectionPoint;
  54393. /**
  54394. * Gets the output component
  54395. */
  54396. readonly output: NodeMaterialConnectionPoint;
  54397. protected _buildBlock(state: NodeMaterialBuildState): this;
  54398. protected _dumpPropertiesCode(): string;
  54399. serialize(): any;
  54400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * Block used to normalize a vector
  54406. */
  54407. export class NormalizeBlock extends NodeMaterialBlock {
  54408. /**
  54409. * Creates a new NormalizeBlock
  54410. * @param name defines the block name
  54411. */
  54412. constructor(name: string);
  54413. /**
  54414. * Gets the current class name
  54415. * @returns the class name
  54416. */
  54417. getClassName(): string;
  54418. /**
  54419. * Gets the input component
  54420. */
  54421. readonly input: NodeMaterialConnectionPoint;
  54422. /**
  54423. * Gets the output component
  54424. */
  54425. readonly output: NodeMaterialConnectionPoint;
  54426. protected _buildBlock(state: NodeMaterialBuildState): this;
  54427. }
  54428. }
  54429. declare module BABYLON {
  54430. /**
  54431. * Operations supported by the Trigonometry block
  54432. */
  54433. export enum TrigonometryBlockOperations {
  54434. /** Cos */
  54435. Cos = 0,
  54436. /** Sin */
  54437. Sin = 1,
  54438. /** Abs */
  54439. Abs = 2,
  54440. /** Exp */
  54441. Exp = 3,
  54442. /** Exp2 */
  54443. Exp2 = 4,
  54444. /** Round */
  54445. Round = 5,
  54446. /** Floor */
  54447. Floor = 6,
  54448. /** Ceiling */
  54449. Ceiling = 7,
  54450. /** Square root */
  54451. Sqrt = 8
  54452. }
  54453. /**
  54454. * Block used to apply trigonometry operation to floats
  54455. */
  54456. export class TrigonometryBlock extends NodeMaterialBlock {
  54457. /**
  54458. * Gets or sets the operation applied by the block
  54459. */
  54460. operation: TrigonometryBlockOperations;
  54461. /**
  54462. * Creates a new TrigonometryBlock
  54463. * @param name defines the block name
  54464. */
  54465. constructor(name: string);
  54466. /**
  54467. * Gets the current class name
  54468. * @returns the class name
  54469. */
  54470. getClassName(): string;
  54471. /**
  54472. * Gets the input component
  54473. */
  54474. readonly input: NodeMaterialConnectionPoint;
  54475. /**
  54476. * Gets the output component
  54477. */
  54478. readonly output: NodeMaterialConnectionPoint;
  54479. protected _buildBlock(state: NodeMaterialBuildState): this;
  54480. serialize(): any;
  54481. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54482. }
  54483. }
  54484. declare module BABYLON {
  54485. /**
  54486. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54487. */
  54488. export class ColorMergerBlock extends NodeMaterialBlock {
  54489. /**
  54490. * Create a new ColorMergerBlock
  54491. * @param name defines the block name
  54492. */
  54493. constructor(name: string);
  54494. /**
  54495. * Gets the current class name
  54496. * @returns the class name
  54497. */
  54498. getClassName(): string;
  54499. /**
  54500. * Gets the r component (input)
  54501. */
  54502. readonly r: NodeMaterialConnectionPoint;
  54503. /**
  54504. * Gets the g component (input)
  54505. */
  54506. readonly g: NodeMaterialConnectionPoint;
  54507. /**
  54508. * Gets the b component (input)
  54509. */
  54510. readonly b: NodeMaterialConnectionPoint;
  54511. /**
  54512. * Gets the a component (input)
  54513. */
  54514. readonly a: NodeMaterialConnectionPoint;
  54515. /**
  54516. * Gets the rgba component (output)
  54517. */
  54518. readonly rgba: NodeMaterialConnectionPoint;
  54519. /**
  54520. * Gets the rgb component (output)
  54521. */
  54522. readonly rgb: NodeMaterialConnectionPoint;
  54523. protected _buildBlock(state: NodeMaterialBuildState): this;
  54524. }
  54525. }
  54526. declare module BABYLON {
  54527. /**
  54528. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54529. */
  54530. export class VectorMergerBlock extends NodeMaterialBlock {
  54531. /**
  54532. * Create a new VectorMergerBlock
  54533. * @param name defines the block name
  54534. */
  54535. constructor(name: string);
  54536. /**
  54537. * Gets the current class name
  54538. * @returns the class name
  54539. */
  54540. getClassName(): string;
  54541. /**
  54542. * Gets the x component (input)
  54543. */
  54544. readonly x: NodeMaterialConnectionPoint;
  54545. /**
  54546. * Gets the y component (input)
  54547. */
  54548. readonly y: NodeMaterialConnectionPoint;
  54549. /**
  54550. * Gets the z component (input)
  54551. */
  54552. readonly z: NodeMaterialConnectionPoint;
  54553. /**
  54554. * Gets the w component (input)
  54555. */
  54556. readonly w: NodeMaterialConnectionPoint;
  54557. /**
  54558. * Gets the xyzw component (output)
  54559. */
  54560. readonly xyzw: NodeMaterialConnectionPoint;
  54561. /**
  54562. * Gets the xyz component (output)
  54563. */
  54564. readonly xyz: NodeMaterialConnectionPoint;
  54565. /**
  54566. * Gets the xy component (output)
  54567. */
  54568. readonly xy: NodeMaterialConnectionPoint;
  54569. protected _buildBlock(state: NodeMaterialBuildState): this;
  54570. }
  54571. }
  54572. declare module BABYLON {
  54573. /**
  54574. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54575. */
  54576. export class ColorSplitterBlock extends NodeMaterialBlock {
  54577. /**
  54578. * Create a new ColorSplitterBlock
  54579. * @param name defines the block name
  54580. */
  54581. constructor(name: string);
  54582. /**
  54583. * Gets the current class name
  54584. * @returns the class name
  54585. */
  54586. getClassName(): string;
  54587. /**
  54588. * Gets the rgba component (input)
  54589. */
  54590. readonly rgba: NodeMaterialConnectionPoint;
  54591. /**
  54592. * Gets the rgb component (input)
  54593. */
  54594. readonly rgbIn: NodeMaterialConnectionPoint;
  54595. /**
  54596. * Gets the rgb component (output)
  54597. */
  54598. readonly rgbOut: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the r component (output)
  54601. */
  54602. readonly r: NodeMaterialConnectionPoint;
  54603. /**
  54604. * Gets the g component (output)
  54605. */
  54606. readonly g: NodeMaterialConnectionPoint;
  54607. /**
  54608. * Gets the b component (output)
  54609. */
  54610. readonly b: NodeMaterialConnectionPoint;
  54611. /**
  54612. * Gets the a component (output)
  54613. */
  54614. readonly a: NodeMaterialConnectionPoint;
  54615. protected _inputRename(name: string): string;
  54616. protected _outputRename(name: string): string;
  54617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54618. }
  54619. }
  54620. declare module BABYLON {
  54621. /**
  54622. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54623. */
  54624. export class VectorSplitterBlock extends NodeMaterialBlock {
  54625. /**
  54626. * Create a new VectorSplitterBlock
  54627. * @param name defines the block name
  54628. */
  54629. constructor(name: string);
  54630. /**
  54631. * Gets the current class name
  54632. * @returns the class name
  54633. */
  54634. getClassName(): string;
  54635. /**
  54636. * Gets the xyzw component (input)
  54637. */
  54638. readonly xyzw: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the xyz component (input)
  54641. */
  54642. readonly xyzIn: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the xy component (input)
  54645. */
  54646. readonly xyIn: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the xyz component (output)
  54649. */
  54650. readonly xyzOut: NodeMaterialConnectionPoint;
  54651. /**
  54652. * Gets the xy component (output)
  54653. */
  54654. readonly xyOut: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the x component (output)
  54657. */
  54658. readonly x: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the y component (output)
  54661. */
  54662. readonly y: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the z component (output)
  54665. */
  54666. readonly z: NodeMaterialConnectionPoint;
  54667. /**
  54668. * Gets the w component (output)
  54669. */
  54670. readonly w: NodeMaterialConnectionPoint;
  54671. protected _inputRename(name: string): string;
  54672. protected _outputRename(name: string): string;
  54673. protected _buildBlock(state: NodeMaterialBuildState): this;
  54674. }
  54675. }
  54676. declare module BABYLON {
  54677. /**
  54678. * Block used to lerp 2 values
  54679. */
  54680. export class LerpBlock extends NodeMaterialBlock {
  54681. /**
  54682. * Creates a new LerpBlock
  54683. * @param name defines the block name
  54684. */
  54685. constructor(name: string);
  54686. /**
  54687. * Gets the current class name
  54688. * @returns the class name
  54689. */
  54690. getClassName(): string;
  54691. /**
  54692. * Gets the left operand input component
  54693. */
  54694. readonly left: NodeMaterialConnectionPoint;
  54695. /**
  54696. * Gets the right operand input component
  54697. */
  54698. readonly right: NodeMaterialConnectionPoint;
  54699. /**
  54700. * Gets the gradient operand input component
  54701. */
  54702. readonly gradient: NodeMaterialConnectionPoint;
  54703. /**
  54704. * Gets the output component
  54705. */
  54706. readonly output: NodeMaterialConnectionPoint;
  54707. protected _buildBlock(state: NodeMaterialBuildState): this;
  54708. }
  54709. }
  54710. declare module BABYLON {
  54711. /**
  54712. * Block used to divide 2 vectors
  54713. */
  54714. export class DivideBlock extends NodeMaterialBlock {
  54715. /**
  54716. * Creates a new DivideBlock
  54717. * @param name defines the block name
  54718. */
  54719. constructor(name: string);
  54720. /**
  54721. * Gets the current class name
  54722. * @returns the class name
  54723. */
  54724. getClassName(): string;
  54725. /**
  54726. * Gets the left operand input component
  54727. */
  54728. readonly left: NodeMaterialConnectionPoint;
  54729. /**
  54730. * Gets the right operand input component
  54731. */
  54732. readonly right: NodeMaterialConnectionPoint;
  54733. /**
  54734. * Gets the output component
  54735. */
  54736. readonly output: NodeMaterialConnectionPoint;
  54737. protected _buildBlock(state: NodeMaterialBuildState): this;
  54738. }
  54739. }
  54740. declare module BABYLON {
  54741. /**
  54742. * Block used to subtract 2 vectors
  54743. */
  54744. export class SubtractBlock extends NodeMaterialBlock {
  54745. /**
  54746. * Creates a new SubtractBlock
  54747. * @param name defines the block name
  54748. */
  54749. constructor(name: string);
  54750. /**
  54751. * Gets the current class name
  54752. * @returns the class name
  54753. */
  54754. getClassName(): string;
  54755. /**
  54756. * Gets the left operand input component
  54757. */
  54758. readonly left: NodeMaterialConnectionPoint;
  54759. /**
  54760. * Gets the right operand input component
  54761. */
  54762. readonly right: NodeMaterialConnectionPoint;
  54763. /**
  54764. * Gets the output component
  54765. */
  54766. readonly output: NodeMaterialConnectionPoint;
  54767. protected _buildBlock(state: NodeMaterialBuildState): this;
  54768. }
  54769. }
  54770. declare module BABYLON {
  54771. /**
  54772. * Block used to step a value
  54773. */
  54774. export class StepBlock extends NodeMaterialBlock {
  54775. /**
  54776. * Creates a new AddBlock
  54777. * @param name defines the block name
  54778. */
  54779. constructor(name: string);
  54780. /**
  54781. * Gets the current class name
  54782. * @returns the class name
  54783. */
  54784. getClassName(): string;
  54785. /**
  54786. * Gets the value operand input component
  54787. */
  54788. readonly value: NodeMaterialConnectionPoint;
  54789. /**
  54790. * Gets the edge operand input component
  54791. */
  54792. readonly edge: NodeMaterialConnectionPoint;
  54793. /**
  54794. * Gets the output component
  54795. */
  54796. readonly output: NodeMaterialConnectionPoint;
  54797. protected _buildBlock(state: NodeMaterialBuildState): this;
  54798. }
  54799. }
  54800. declare module BABYLON {
  54801. /**
  54802. * Block used to get the opposite (1 - x) of a value
  54803. */
  54804. export class OneMinusBlock extends NodeMaterialBlock {
  54805. /**
  54806. * Creates a new OneMinusBlock
  54807. * @param name defines the block name
  54808. */
  54809. constructor(name: string);
  54810. /**
  54811. * Gets the current class name
  54812. * @returns the class name
  54813. */
  54814. getClassName(): string;
  54815. /**
  54816. * Gets the input component
  54817. */
  54818. readonly input: NodeMaterialConnectionPoint;
  54819. /**
  54820. * Gets the output component
  54821. */
  54822. readonly output: NodeMaterialConnectionPoint;
  54823. protected _buildBlock(state: NodeMaterialBuildState): this;
  54824. }
  54825. }
  54826. declare module BABYLON {
  54827. /**
  54828. * Block used to get the view direction
  54829. */
  54830. export class ViewDirectionBlock extends NodeMaterialBlock {
  54831. /**
  54832. * Creates a new ViewDirectionBlock
  54833. * @param name defines the block name
  54834. */
  54835. constructor(name: string);
  54836. /**
  54837. * Gets the current class name
  54838. * @returns the class name
  54839. */
  54840. getClassName(): string;
  54841. /**
  54842. * Gets the world position component
  54843. */
  54844. readonly worldPosition: NodeMaterialConnectionPoint;
  54845. /**
  54846. * Gets the camera position component
  54847. */
  54848. readonly cameraPosition: NodeMaterialConnectionPoint;
  54849. /**
  54850. * Gets the output component
  54851. */
  54852. readonly output: NodeMaterialConnectionPoint;
  54853. autoConfigure(material: NodeMaterial): void;
  54854. protected _buildBlock(state: NodeMaterialBuildState): this;
  54855. }
  54856. }
  54857. declare module BABYLON {
  54858. /**
  54859. * Block used to compute fresnel value
  54860. */
  54861. export class FresnelBlock extends NodeMaterialBlock {
  54862. /**
  54863. * Create a new FresnelBlock
  54864. * @param name defines the block name
  54865. */
  54866. constructor(name: string);
  54867. /**
  54868. * Gets the current class name
  54869. * @returns the class name
  54870. */
  54871. getClassName(): string;
  54872. /**
  54873. * Gets the world normal input component
  54874. */
  54875. readonly worldNormal: NodeMaterialConnectionPoint;
  54876. /**
  54877. * Gets the view direction input component
  54878. */
  54879. readonly viewDirection: NodeMaterialConnectionPoint;
  54880. /**
  54881. * Gets the bias input component
  54882. */
  54883. readonly bias: NodeMaterialConnectionPoint;
  54884. /**
  54885. * Gets the camera (or eye) position component
  54886. */
  54887. readonly power: NodeMaterialConnectionPoint;
  54888. /**
  54889. * Gets the fresnel output component
  54890. */
  54891. readonly fresnel: NodeMaterialConnectionPoint;
  54892. autoConfigure(material: NodeMaterial): void;
  54893. protected _buildBlock(state: NodeMaterialBuildState): this;
  54894. }
  54895. }
  54896. declare module BABYLON {
  54897. /**
  54898. * Block used to get the max of 2 values
  54899. */
  54900. export class MaxBlock extends NodeMaterialBlock {
  54901. /**
  54902. * Creates a new MaxBlock
  54903. * @param name defines the block name
  54904. */
  54905. constructor(name: string);
  54906. /**
  54907. * Gets the current class name
  54908. * @returns the class name
  54909. */
  54910. getClassName(): string;
  54911. /**
  54912. * Gets the left operand input component
  54913. */
  54914. readonly left: NodeMaterialConnectionPoint;
  54915. /**
  54916. * Gets the right operand input component
  54917. */
  54918. readonly right: NodeMaterialConnectionPoint;
  54919. /**
  54920. * Gets the output component
  54921. */
  54922. readonly output: NodeMaterialConnectionPoint;
  54923. protected _buildBlock(state: NodeMaterialBuildState): this;
  54924. }
  54925. }
  54926. declare module BABYLON {
  54927. /**
  54928. * Block used to get the min of 2 values
  54929. */
  54930. export class MinBlock extends NodeMaterialBlock {
  54931. /**
  54932. * Creates a new MinBlock
  54933. * @param name defines the block name
  54934. */
  54935. constructor(name: string);
  54936. /**
  54937. * Gets the current class name
  54938. * @returns the class name
  54939. */
  54940. getClassName(): string;
  54941. /**
  54942. * Gets the left operand input component
  54943. */
  54944. readonly left: NodeMaterialConnectionPoint;
  54945. /**
  54946. * Gets the right operand input component
  54947. */
  54948. readonly right: NodeMaterialConnectionPoint;
  54949. /**
  54950. * Gets the output component
  54951. */
  54952. readonly output: NodeMaterialConnectionPoint;
  54953. protected _buildBlock(state: NodeMaterialBuildState): this;
  54954. }
  54955. }
  54956. declare module BABYLON {
  54957. /**
  54958. * Block used to get the distance between 2 values
  54959. */
  54960. export class DistanceBlock extends NodeMaterialBlock {
  54961. /**
  54962. * Creates a new DistanceBlock
  54963. * @param name defines the block name
  54964. */
  54965. constructor(name: string);
  54966. /**
  54967. * Gets the current class name
  54968. * @returns the class name
  54969. */
  54970. getClassName(): string;
  54971. /**
  54972. * Gets the left operand input component
  54973. */
  54974. readonly left: NodeMaterialConnectionPoint;
  54975. /**
  54976. * Gets the right operand input component
  54977. */
  54978. readonly right: NodeMaterialConnectionPoint;
  54979. /**
  54980. * Gets the output component
  54981. */
  54982. readonly output: NodeMaterialConnectionPoint;
  54983. protected _buildBlock(state: NodeMaterialBuildState): this;
  54984. }
  54985. }
  54986. declare module BABYLON {
  54987. /**
  54988. * Block used to get the length of a vector
  54989. */
  54990. export class LengthBlock extends NodeMaterialBlock {
  54991. /**
  54992. * Creates a new LengthBlock
  54993. * @param name defines the block name
  54994. */
  54995. constructor(name: string);
  54996. /**
  54997. * Gets the current class name
  54998. * @returns the class name
  54999. */
  55000. getClassName(): string;
  55001. /**
  55002. * Gets the value input component
  55003. */
  55004. readonly value: NodeMaterialConnectionPoint;
  55005. /**
  55006. * Gets the output component
  55007. */
  55008. readonly output: NodeMaterialConnectionPoint;
  55009. protected _buildBlock(state: NodeMaterialBuildState): this;
  55010. }
  55011. }
  55012. declare module BABYLON {
  55013. /**
  55014. * Block used to get negative version of a value (i.e. x * -1)
  55015. */
  55016. export class NegateBlock extends NodeMaterialBlock {
  55017. /**
  55018. * Creates a new NegateBlock
  55019. * @param name defines the block name
  55020. */
  55021. constructor(name: string);
  55022. /**
  55023. * Gets the current class name
  55024. * @returns the class name
  55025. */
  55026. getClassName(): string;
  55027. /**
  55028. * Gets the value input component
  55029. */
  55030. readonly value: NodeMaterialConnectionPoint;
  55031. /**
  55032. * Gets the output component
  55033. */
  55034. readonly output: NodeMaterialConnectionPoint;
  55035. protected _buildBlock(state: NodeMaterialBuildState): this;
  55036. }
  55037. }
  55038. declare module BABYLON {
  55039. /**
  55040. * Block used to get the value of the first parameter raised to the power of the second
  55041. */
  55042. export class PowBlock extends NodeMaterialBlock {
  55043. /**
  55044. * Creates a new PowBlock
  55045. * @param name defines the block name
  55046. */
  55047. constructor(name: string);
  55048. /**
  55049. * Gets the current class name
  55050. * @returns the class name
  55051. */
  55052. getClassName(): string;
  55053. /**
  55054. * Gets the value operand input component
  55055. */
  55056. readonly value: NodeMaterialConnectionPoint;
  55057. /**
  55058. * Gets the power operand input component
  55059. */
  55060. readonly power: NodeMaterialConnectionPoint;
  55061. /**
  55062. * Gets the output component
  55063. */
  55064. readonly output: NodeMaterialConnectionPoint;
  55065. protected _buildBlock(state: NodeMaterialBuildState): this;
  55066. }
  55067. }
  55068. declare module BABYLON {
  55069. /**
  55070. * Block used to get a random number
  55071. */
  55072. export class RandomNumberBlock extends NodeMaterialBlock {
  55073. /**
  55074. * Creates a new RandomNumberBlock
  55075. * @param name defines the block name
  55076. */
  55077. constructor(name: string);
  55078. /**
  55079. * Gets the current class name
  55080. * @returns the class name
  55081. */
  55082. getClassName(): string;
  55083. /**
  55084. * Gets the seed input component
  55085. */
  55086. readonly seed: NodeMaterialConnectionPoint;
  55087. /**
  55088. * Gets the output component
  55089. */
  55090. readonly output: NodeMaterialConnectionPoint;
  55091. protected _buildBlock(state: NodeMaterialBuildState): this;
  55092. }
  55093. }
  55094. declare module BABYLON {
  55095. /**
  55096. * Effect Render Options
  55097. */
  55098. export interface IEffectRendererOptions {
  55099. /**
  55100. * Defines the vertices positions.
  55101. */
  55102. positions?: number[];
  55103. /**
  55104. * Defines the indices.
  55105. */
  55106. indices?: number[];
  55107. }
  55108. /**
  55109. * Helper class to render one or more effects
  55110. */
  55111. export class EffectRenderer {
  55112. private engine;
  55113. private static _DefaultOptions;
  55114. private _vertexBuffers;
  55115. private _indexBuffer;
  55116. private _ringBufferIndex;
  55117. private _ringScreenBuffer;
  55118. private _fullscreenViewport;
  55119. private _getNextFrameBuffer;
  55120. /**
  55121. * Creates an effect renderer
  55122. * @param engine the engine to use for rendering
  55123. * @param options defines the options of the effect renderer
  55124. */
  55125. constructor(engine: Engine, options?: IEffectRendererOptions);
  55126. /**
  55127. * Sets the current viewport in normalized coordinates 0-1
  55128. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55129. */
  55130. setViewport(viewport?: Viewport): void;
  55131. /**
  55132. * Binds the embedded attributes buffer to the effect.
  55133. * @param effect Defines the effect to bind the attributes for
  55134. */
  55135. bindBuffers(effect: Effect): void;
  55136. /**
  55137. * Sets the current effect wrapper to use during draw.
  55138. * The effect needs to be ready before calling this api.
  55139. * This also sets the default full screen position attribute.
  55140. * @param effectWrapper Defines the effect to draw with
  55141. */
  55142. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55143. /**
  55144. * Draws a full screen quad.
  55145. */
  55146. draw(): void;
  55147. /**
  55148. * renders one or more effects to a specified texture
  55149. * @param effectWrappers list of effects to renderer
  55150. * @param outputTexture texture to draw to, if null it will render to the screen
  55151. */
  55152. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55153. /**
  55154. * Disposes of the effect renderer
  55155. */
  55156. dispose(): void;
  55157. }
  55158. /**
  55159. * Options to create an EffectWrapper
  55160. */
  55161. interface EffectWrapperCreationOptions {
  55162. /**
  55163. * Engine to use to create the effect
  55164. */
  55165. engine: Engine;
  55166. /**
  55167. * Fragment shader for the effect
  55168. */
  55169. fragmentShader: string;
  55170. /**
  55171. * Vertex shader for the effect
  55172. */
  55173. vertexShader?: string;
  55174. /**
  55175. * Attributes to use in the shader
  55176. */
  55177. attributeNames?: Array<string>;
  55178. /**
  55179. * Uniforms to use in the shader
  55180. */
  55181. uniformNames?: Array<string>;
  55182. /**
  55183. * Texture sampler names to use in the shader
  55184. */
  55185. samplerNames?: Array<string>;
  55186. /**
  55187. * The friendly name of the effect displayed in Spector.
  55188. */
  55189. name?: string;
  55190. }
  55191. /**
  55192. * Wraps an effect to be used for rendering
  55193. */
  55194. export class EffectWrapper {
  55195. /**
  55196. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55197. */
  55198. onApplyObservable: Observable<{}>;
  55199. /**
  55200. * The underlying effect
  55201. */
  55202. effect: Effect;
  55203. /**
  55204. * Creates an effect to be renderer
  55205. * @param creationOptions options to create the effect
  55206. */
  55207. constructor(creationOptions: EffectWrapperCreationOptions);
  55208. /**
  55209. * Disposes of the effect wrapper
  55210. */
  55211. dispose(): void;
  55212. }
  55213. }
  55214. declare module BABYLON {
  55215. /**
  55216. * Helper class to push actions to a pool of workers.
  55217. */
  55218. export class WorkerPool implements IDisposable {
  55219. private _workerInfos;
  55220. private _pendingActions;
  55221. /**
  55222. * Constructor
  55223. * @param workers Array of workers to use for actions
  55224. */
  55225. constructor(workers: Array<Worker>);
  55226. /**
  55227. * Terminates all workers and clears any pending actions.
  55228. */
  55229. dispose(): void;
  55230. /**
  55231. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55232. * pended until a worker has completed its action.
  55233. * @param action The action to perform. Call onComplete when the action is complete.
  55234. */
  55235. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55236. private _execute;
  55237. }
  55238. }
  55239. declare module BABYLON {
  55240. /**
  55241. * Configuration for Draco compression
  55242. */
  55243. export interface IDracoCompressionConfiguration {
  55244. /**
  55245. * Configuration for the decoder.
  55246. */
  55247. decoder: {
  55248. /**
  55249. * The url to the WebAssembly module.
  55250. */
  55251. wasmUrl?: string;
  55252. /**
  55253. * The url to the WebAssembly binary.
  55254. */
  55255. wasmBinaryUrl?: string;
  55256. /**
  55257. * The url to the fallback JavaScript module.
  55258. */
  55259. fallbackUrl?: string;
  55260. };
  55261. }
  55262. /**
  55263. * Draco compression (https://google.github.io/draco/)
  55264. *
  55265. * This class wraps the Draco module.
  55266. *
  55267. * **Encoder**
  55268. *
  55269. * The encoder is not currently implemented.
  55270. *
  55271. * **Decoder**
  55272. *
  55273. * 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.
  55274. *
  55275. * To update the configuration, use the following code:
  55276. * ```javascript
  55277. * DracoCompression.Configuration = {
  55278. * decoder: {
  55279. * wasmUrl: "<url to the WebAssembly library>",
  55280. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55281. * fallbackUrl: "<url to the fallback JavaScript library>",
  55282. * }
  55283. * };
  55284. * ```
  55285. *
  55286. * 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.
  55287. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55288. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55289. *
  55290. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55291. * ```javascript
  55292. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55293. * ```
  55294. *
  55295. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55296. */
  55297. export class DracoCompression implements IDisposable {
  55298. private _workerPoolPromise?;
  55299. private _decoderModulePromise?;
  55300. /**
  55301. * The configuration. Defaults to the following urls:
  55302. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55303. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55304. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55305. */
  55306. static Configuration: IDracoCompressionConfiguration;
  55307. /**
  55308. * Returns true if the decoder configuration is available.
  55309. */
  55310. static readonly DecoderAvailable: boolean;
  55311. /**
  55312. * Default number of workers to create when creating the draco compression object.
  55313. */
  55314. static DefaultNumWorkers: number;
  55315. private static GetDefaultNumWorkers;
  55316. private static _Default;
  55317. /**
  55318. * Default instance for the draco compression object.
  55319. */
  55320. static readonly Default: DracoCompression;
  55321. /**
  55322. * Constructor
  55323. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55324. */
  55325. constructor(numWorkers?: number);
  55326. /**
  55327. * Stop all async operations and release resources.
  55328. */
  55329. dispose(): void;
  55330. /**
  55331. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55332. * @returns a promise that resolves when ready
  55333. */
  55334. whenReadyAsync(): Promise<void>;
  55335. /**
  55336. * Decode Draco compressed mesh data to vertex data.
  55337. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55338. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55339. * @returns A promise that resolves with the decoded vertex data
  55340. */
  55341. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55342. [kind: string]: number;
  55343. }): Promise<VertexData>;
  55344. }
  55345. }
  55346. declare module BABYLON {
  55347. /**
  55348. * Class for building Constructive Solid Geometry
  55349. */
  55350. export class CSG {
  55351. private polygons;
  55352. /**
  55353. * The world matrix
  55354. */
  55355. matrix: Matrix;
  55356. /**
  55357. * Stores the position
  55358. */
  55359. position: Vector3;
  55360. /**
  55361. * Stores the rotation
  55362. */
  55363. rotation: Vector3;
  55364. /**
  55365. * Stores the rotation quaternion
  55366. */
  55367. rotationQuaternion: Nullable<Quaternion>;
  55368. /**
  55369. * Stores the scaling vector
  55370. */
  55371. scaling: Vector3;
  55372. /**
  55373. * Convert the Mesh to CSG
  55374. * @param mesh The Mesh to convert to CSG
  55375. * @returns A new CSG from the Mesh
  55376. */
  55377. static FromMesh(mesh: Mesh): CSG;
  55378. /**
  55379. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55380. * @param polygons Polygons used to construct a CSG solid
  55381. */
  55382. private static FromPolygons;
  55383. /**
  55384. * Clones, or makes a deep copy, of the CSG
  55385. * @returns A new CSG
  55386. */
  55387. clone(): CSG;
  55388. /**
  55389. * Unions this CSG with another CSG
  55390. * @param csg The CSG to union against this CSG
  55391. * @returns The unioned CSG
  55392. */
  55393. union(csg: CSG): CSG;
  55394. /**
  55395. * Unions this CSG with another CSG in place
  55396. * @param csg The CSG to union against this CSG
  55397. */
  55398. unionInPlace(csg: CSG): void;
  55399. /**
  55400. * Subtracts this CSG with another CSG
  55401. * @param csg The CSG to subtract against this CSG
  55402. * @returns A new CSG
  55403. */
  55404. subtract(csg: CSG): CSG;
  55405. /**
  55406. * Subtracts this CSG with another CSG in place
  55407. * @param csg The CSG to subtact against this CSG
  55408. */
  55409. subtractInPlace(csg: CSG): void;
  55410. /**
  55411. * Intersect this CSG with another CSG
  55412. * @param csg The CSG to intersect against this CSG
  55413. * @returns A new CSG
  55414. */
  55415. intersect(csg: CSG): CSG;
  55416. /**
  55417. * Intersects this CSG with another CSG in place
  55418. * @param csg The CSG to intersect against this CSG
  55419. */
  55420. intersectInPlace(csg: CSG): void;
  55421. /**
  55422. * Return a new CSG solid with solid and empty space switched. This solid is
  55423. * not modified.
  55424. * @returns A new CSG solid with solid and empty space switched
  55425. */
  55426. inverse(): CSG;
  55427. /**
  55428. * Inverses the CSG in place
  55429. */
  55430. inverseInPlace(): void;
  55431. /**
  55432. * This is used to keep meshes transformations so they can be restored
  55433. * when we build back a Babylon Mesh
  55434. * NB : All CSG operations are performed in world coordinates
  55435. * @param csg The CSG to copy the transform attributes from
  55436. * @returns This CSG
  55437. */
  55438. copyTransformAttributes(csg: CSG): CSG;
  55439. /**
  55440. * Build Raw mesh from CSG
  55441. * Coordinates here are in world space
  55442. * @param name The name of the mesh geometry
  55443. * @param scene The Scene
  55444. * @param keepSubMeshes Specifies if the submeshes should be kept
  55445. * @returns A new Mesh
  55446. */
  55447. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55448. /**
  55449. * Build Mesh from CSG taking material and transforms into account
  55450. * @param name The name of the Mesh
  55451. * @param material The material of the Mesh
  55452. * @param scene The Scene
  55453. * @param keepSubMeshes Specifies if submeshes should be kept
  55454. * @returns The new Mesh
  55455. */
  55456. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55457. }
  55458. }
  55459. declare module BABYLON {
  55460. /**
  55461. * Class used to create a trail following a mesh
  55462. */
  55463. export class TrailMesh extends Mesh {
  55464. private _generator;
  55465. private _autoStart;
  55466. private _running;
  55467. private _diameter;
  55468. private _length;
  55469. private _sectionPolygonPointsCount;
  55470. private _sectionVectors;
  55471. private _sectionNormalVectors;
  55472. private _beforeRenderObserver;
  55473. /**
  55474. * @constructor
  55475. * @param name The value used by scene.getMeshByName() to do a lookup.
  55476. * @param generator The mesh to generate a trail.
  55477. * @param scene The scene to add this mesh to.
  55478. * @param diameter Diameter of trailing mesh. Default is 1.
  55479. * @param length Length of trailing mesh. Default is 60.
  55480. * @param autoStart Automatically start trailing mesh. Default true.
  55481. */
  55482. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55483. /**
  55484. * "TrailMesh"
  55485. * @returns "TrailMesh"
  55486. */
  55487. getClassName(): string;
  55488. private _createMesh;
  55489. /**
  55490. * Start trailing mesh.
  55491. */
  55492. start(): void;
  55493. /**
  55494. * Stop trailing mesh.
  55495. */
  55496. stop(): void;
  55497. /**
  55498. * Update trailing mesh geometry.
  55499. */
  55500. update(): void;
  55501. /**
  55502. * Returns a new TrailMesh object.
  55503. * @param name is a string, the name given to the new mesh
  55504. * @param newGenerator use new generator object for cloned trail mesh
  55505. * @returns a new mesh
  55506. */
  55507. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55508. /**
  55509. * Serializes this trail mesh
  55510. * @param serializationObject object to write serialization to
  55511. */
  55512. serialize(serializationObject: any): void;
  55513. /**
  55514. * Parses a serialized trail mesh
  55515. * @param parsedMesh the serialized mesh
  55516. * @param scene the scene to create the trail mesh in
  55517. * @returns the created trail mesh
  55518. */
  55519. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55520. }
  55521. }
  55522. declare module BABYLON {
  55523. /**
  55524. * Class containing static functions to help procedurally build meshes
  55525. */
  55526. export class TiledBoxBuilder {
  55527. /**
  55528. * Creates a box mesh
  55529. * 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)
  55530. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55532. * * 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
  55533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55534. * @param name defines the name of the mesh
  55535. * @param options defines the options used to create the mesh
  55536. * @param scene defines the hosting scene
  55537. * @returns the box mesh
  55538. */
  55539. static CreateTiledBox(name: string, options: {
  55540. pattern?: number;
  55541. width?: number;
  55542. height?: number;
  55543. depth?: number;
  55544. tileSize?: number;
  55545. tileWidth?: number;
  55546. tileHeight?: number;
  55547. alignHorizontal?: number;
  55548. alignVertical?: number;
  55549. faceUV?: Vector4[];
  55550. faceColors?: Color4[];
  55551. sideOrientation?: number;
  55552. updatable?: boolean;
  55553. }, scene?: Nullable<Scene>): Mesh;
  55554. }
  55555. }
  55556. declare module BABYLON {
  55557. /**
  55558. * Class containing static functions to help procedurally build meshes
  55559. */
  55560. export class TorusKnotBuilder {
  55561. /**
  55562. * Creates a torus knot mesh
  55563. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55564. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55565. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55566. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55568. * * 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
  55569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55570. * @param name defines the name of the mesh
  55571. * @param options defines the options used to create the mesh
  55572. * @param scene defines the hosting scene
  55573. * @returns the torus knot mesh
  55574. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55575. */
  55576. static CreateTorusKnot(name: string, options: {
  55577. radius?: number;
  55578. tube?: number;
  55579. radialSegments?: number;
  55580. tubularSegments?: number;
  55581. p?: number;
  55582. q?: number;
  55583. updatable?: boolean;
  55584. sideOrientation?: number;
  55585. frontUVs?: Vector4;
  55586. backUVs?: Vector4;
  55587. }, scene: any): Mesh;
  55588. }
  55589. }
  55590. declare module BABYLON {
  55591. /**
  55592. * Polygon
  55593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55594. */
  55595. export class Polygon {
  55596. /**
  55597. * Creates a rectangle
  55598. * @param xmin bottom X coord
  55599. * @param ymin bottom Y coord
  55600. * @param xmax top X coord
  55601. * @param ymax top Y coord
  55602. * @returns points that make the resulting rectation
  55603. */
  55604. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55605. /**
  55606. * Creates a circle
  55607. * @param radius radius of circle
  55608. * @param cx scale in x
  55609. * @param cy scale in y
  55610. * @param numberOfSides number of sides that make up the circle
  55611. * @returns points that make the resulting circle
  55612. */
  55613. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55614. /**
  55615. * Creates a polygon from input string
  55616. * @param input Input polygon data
  55617. * @returns the parsed points
  55618. */
  55619. static Parse(input: string): Vector2[];
  55620. /**
  55621. * Starts building a polygon from x and y coordinates
  55622. * @param x x coordinate
  55623. * @param y y coordinate
  55624. * @returns the started path2
  55625. */
  55626. static StartingAt(x: number, y: number): Path2;
  55627. }
  55628. /**
  55629. * Builds a polygon
  55630. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55631. */
  55632. export class PolygonMeshBuilder {
  55633. private _points;
  55634. private _outlinepoints;
  55635. private _holes;
  55636. private _name;
  55637. private _scene;
  55638. private _epoints;
  55639. private _eholes;
  55640. private _addToepoint;
  55641. /**
  55642. * Babylon reference to the earcut plugin.
  55643. */
  55644. bjsEarcut: any;
  55645. /**
  55646. * Creates a PolygonMeshBuilder
  55647. * @param name name of the builder
  55648. * @param contours Path of the polygon
  55649. * @param scene scene to add to when creating the mesh
  55650. * @param earcutInjection can be used to inject your own earcut reference
  55651. */
  55652. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55653. /**
  55654. * Adds a whole within the polygon
  55655. * @param hole Array of points defining the hole
  55656. * @returns this
  55657. */
  55658. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55659. /**
  55660. * Creates the polygon
  55661. * @param updatable If the mesh should be updatable
  55662. * @param depth The depth of the mesh created
  55663. * @returns the created mesh
  55664. */
  55665. build(updatable?: boolean, depth?: number): Mesh;
  55666. /**
  55667. * Creates the polygon
  55668. * @param depth The depth of the mesh created
  55669. * @returns the created VertexData
  55670. */
  55671. buildVertexData(depth?: number): VertexData;
  55672. /**
  55673. * Adds a side to the polygon
  55674. * @param positions points that make the polygon
  55675. * @param normals normals of the polygon
  55676. * @param uvs uvs of the polygon
  55677. * @param indices indices of the polygon
  55678. * @param bounds bounds of the polygon
  55679. * @param points points of the polygon
  55680. * @param depth depth of the polygon
  55681. * @param flip flip of the polygon
  55682. */
  55683. private addSide;
  55684. }
  55685. }
  55686. declare module BABYLON {
  55687. /**
  55688. * Class containing static functions to help procedurally build meshes
  55689. */
  55690. export class PolygonBuilder {
  55691. /**
  55692. * Creates a polygon mesh
  55693. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55694. * * 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
  55695. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55697. * * 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)
  55698. * * Remember you can only change the shape positions, not their number when updating a polygon
  55699. * @param name defines the name of the mesh
  55700. * @param options defines the options used to create the mesh
  55701. * @param scene defines the hosting scene
  55702. * @param earcutInjection can be used to inject your own earcut reference
  55703. * @returns the polygon mesh
  55704. */
  55705. static CreatePolygon(name: string, options: {
  55706. shape: Vector3[];
  55707. holes?: Vector3[][];
  55708. depth?: number;
  55709. faceUV?: Vector4[];
  55710. faceColors?: Color4[];
  55711. updatable?: boolean;
  55712. sideOrientation?: number;
  55713. frontUVs?: Vector4;
  55714. backUVs?: Vector4;
  55715. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55716. /**
  55717. * Creates an extruded polygon mesh, with depth in the Y direction.
  55718. * * 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)
  55719. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55720. * @param name defines the name of the mesh
  55721. * @param options defines the options used to create the mesh
  55722. * @param scene defines the hosting scene
  55723. * @param earcutInjection can be used to inject your own earcut reference
  55724. * @returns the polygon mesh
  55725. */
  55726. static ExtrudePolygon(name: string, options: {
  55727. shape: Vector3[];
  55728. holes?: Vector3[][];
  55729. depth?: number;
  55730. faceUV?: Vector4[];
  55731. faceColors?: Color4[];
  55732. updatable?: boolean;
  55733. sideOrientation?: number;
  55734. frontUVs?: Vector4;
  55735. backUVs?: Vector4;
  55736. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55737. }
  55738. }
  55739. declare module BABYLON {
  55740. /**
  55741. * Class containing static functions to help procedurally build meshes
  55742. */
  55743. export class LatheBuilder {
  55744. /**
  55745. * Creates lathe mesh.
  55746. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55747. * * 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
  55748. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55749. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55750. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55751. * * 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
  55752. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55753. * * 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
  55754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55755. * * 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
  55756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55758. * @param name defines the name of the mesh
  55759. * @param options defines the options used to create the mesh
  55760. * @param scene defines the hosting scene
  55761. * @returns the lathe mesh
  55762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55763. */
  55764. static CreateLathe(name: string, options: {
  55765. shape: Vector3[];
  55766. radius?: number;
  55767. tessellation?: number;
  55768. clip?: number;
  55769. arc?: number;
  55770. closed?: boolean;
  55771. updatable?: boolean;
  55772. sideOrientation?: number;
  55773. frontUVs?: Vector4;
  55774. backUVs?: Vector4;
  55775. cap?: number;
  55776. invertUV?: boolean;
  55777. }, scene?: Nullable<Scene>): Mesh;
  55778. }
  55779. }
  55780. declare module BABYLON {
  55781. /**
  55782. * Class containing static functions to help procedurally build meshes
  55783. */
  55784. export class TiledPlaneBuilder {
  55785. /**
  55786. * Creates a tiled plane mesh
  55787. * * The parameter `pattern` will, depending on value, do nothing or
  55788. * * * flip (reflect about central vertical) alternate tiles across and up
  55789. * * * flip every tile on alternate rows
  55790. * * * rotate (180 degs) alternate tiles across and up
  55791. * * * rotate every tile on alternate rows
  55792. * * * flip and rotate alternate tiles across and up
  55793. * * * flip and rotate every tile on alternate rows
  55794. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55795. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55796. * * 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
  55797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55798. * * 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)
  55799. * * 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)
  55800. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55801. * @param name defines the name of the mesh
  55802. * @param options defines the options used to create the mesh
  55803. * @param scene defines the hosting scene
  55804. * @returns the box mesh
  55805. */
  55806. static CreateTiledPlane(name: string, options: {
  55807. pattern?: number;
  55808. tileSize?: number;
  55809. tileWidth?: number;
  55810. tileHeight?: number;
  55811. size?: number;
  55812. width?: number;
  55813. height?: number;
  55814. alignHorizontal?: number;
  55815. alignVertical?: number;
  55816. sideOrientation?: number;
  55817. frontUVs?: Vector4;
  55818. backUVs?: Vector4;
  55819. updatable?: boolean;
  55820. }, scene?: Nullable<Scene>): Mesh;
  55821. }
  55822. }
  55823. declare module BABYLON {
  55824. /**
  55825. * Class containing static functions to help procedurally build meshes
  55826. */
  55827. export class TubeBuilder {
  55828. /**
  55829. * Creates a tube mesh.
  55830. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55831. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55832. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55833. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55834. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55835. * * 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)
  55836. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55837. * * 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
  55838. * * 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
  55839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55840. * * 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
  55841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55843. * @param name defines the name of the mesh
  55844. * @param options defines the options used to create the mesh
  55845. * @param scene defines the hosting scene
  55846. * @returns the tube mesh
  55847. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55848. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55849. */
  55850. static CreateTube(name: string, options: {
  55851. path: Vector3[];
  55852. radius?: number;
  55853. tessellation?: number;
  55854. radiusFunction?: {
  55855. (i: number, distance: number): number;
  55856. };
  55857. cap?: number;
  55858. arc?: number;
  55859. updatable?: boolean;
  55860. sideOrientation?: number;
  55861. frontUVs?: Vector4;
  55862. backUVs?: Vector4;
  55863. instance?: Mesh;
  55864. invertUV?: boolean;
  55865. }, scene?: Nullable<Scene>): Mesh;
  55866. }
  55867. }
  55868. declare module BABYLON {
  55869. /**
  55870. * Class containing static functions to help procedurally build meshes
  55871. */
  55872. export class IcoSphereBuilder {
  55873. /**
  55874. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55875. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55876. * * 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`)
  55877. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55878. * * 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
  55879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55880. * * 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
  55881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55882. * @param name defines the name of the mesh
  55883. * @param options defines the options used to create the mesh
  55884. * @param scene defines the hosting scene
  55885. * @returns the icosahedron mesh
  55886. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55887. */
  55888. static CreateIcoSphere(name: string, options: {
  55889. radius?: number;
  55890. radiusX?: number;
  55891. radiusY?: number;
  55892. radiusZ?: number;
  55893. flat?: boolean;
  55894. subdivisions?: number;
  55895. sideOrientation?: number;
  55896. frontUVs?: Vector4;
  55897. backUVs?: Vector4;
  55898. updatable?: boolean;
  55899. }, scene?: Nullable<Scene>): Mesh;
  55900. }
  55901. }
  55902. declare module BABYLON {
  55903. /**
  55904. * Class containing static functions to help procedurally build meshes
  55905. */
  55906. export class DecalBuilder {
  55907. /**
  55908. * Creates a decal mesh.
  55909. * 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
  55910. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55911. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55912. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55913. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55914. * @param name defines the name of the mesh
  55915. * @param sourceMesh defines the mesh where the decal must be applied
  55916. * @param options defines the options used to create the mesh
  55917. * @param scene defines the hosting scene
  55918. * @returns the decal mesh
  55919. * @see https://doc.babylonjs.com/how_to/decals
  55920. */
  55921. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55922. position?: Vector3;
  55923. normal?: Vector3;
  55924. size?: Vector3;
  55925. angle?: number;
  55926. }): Mesh;
  55927. }
  55928. }
  55929. declare module BABYLON {
  55930. /**
  55931. * Class containing static functions to help procedurally build meshes
  55932. */
  55933. export class MeshBuilder {
  55934. /**
  55935. * Creates a box mesh
  55936. * * The parameter `size` sets the size (float) of each box side (default 1)
  55937. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55938. * * 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)
  55939. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55941. * * 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
  55942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55943. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55944. * @param name defines the name of the mesh
  55945. * @param options defines the options used to create the mesh
  55946. * @param scene defines the hosting scene
  55947. * @returns the box mesh
  55948. */
  55949. static CreateBox(name: string, options: {
  55950. size?: number;
  55951. width?: number;
  55952. height?: number;
  55953. depth?: number;
  55954. faceUV?: Vector4[];
  55955. faceColors?: Color4[];
  55956. sideOrientation?: number;
  55957. frontUVs?: Vector4;
  55958. backUVs?: Vector4;
  55959. updatable?: boolean;
  55960. }, scene?: Nullable<Scene>): Mesh;
  55961. /**
  55962. * Creates a tiled box mesh
  55963. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55965. * @param name defines the name of the mesh
  55966. * @param options defines the options used to create the mesh
  55967. * @param scene defines the hosting scene
  55968. * @returns the tiled box mesh
  55969. */
  55970. static CreateTiledBox(name: string, options: {
  55971. pattern?: number;
  55972. size?: number;
  55973. width?: number;
  55974. height?: number;
  55975. depth: number;
  55976. tileSize?: number;
  55977. tileWidth?: number;
  55978. tileHeight?: number;
  55979. faceUV?: Vector4[];
  55980. faceColors?: Color4[];
  55981. alignHorizontal?: number;
  55982. alignVertical?: number;
  55983. sideOrientation?: number;
  55984. updatable?: boolean;
  55985. }, scene?: Nullable<Scene>): Mesh;
  55986. /**
  55987. * Creates a sphere mesh
  55988. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55989. * * 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`)
  55990. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55991. * * 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
  55992. * * 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)
  55993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55994. * * 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
  55995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55996. * @param name defines the name of the mesh
  55997. * @param options defines the options used to create the mesh
  55998. * @param scene defines the hosting scene
  55999. * @returns the sphere mesh
  56000. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56001. */
  56002. static CreateSphere(name: string, options: {
  56003. segments?: number;
  56004. diameter?: number;
  56005. diameterX?: number;
  56006. diameterY?: number;
  56007. diameterZ?: number;
  56008. arc?: number;
  56009. slice?: number;
  56010. sideOrientation?: number;
  56011. frontUVs?: Vector4;
  56012. backUVs?: Vector4;
  56013. updatable?: boolean;
  56014. }, scene?: Nullable<Scene>): Mesh;
  56015. /**
  56016. * Creates a plane polygonal mesh. By default, this is a disc
  56017. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56018. * * 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
  56019. * * 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
  56020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56021. * * 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
  56022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56023. * @param name defines the name of the mesh
  56024. * @param options defines the options used to create the mesh
  56025. * @param scene defines the hosting scene
  56026. * @returns the plane polygonal mesh
  56027. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56028. */
  56029. static CreateDisc(name: string, options: {
  56030. radius?: number;
  56031. tessellation?: number;
  56032. arc?: number;
  56033. updatable?: boolean;
  56034. sideOrientation?: number;
  56035. frontUVs?: Vector4;
  56036. backUVs?: Vector4;
  56037. }, scene?: Nullable<Scene>): Mesh;
  56038. /**
  56039. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56040. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56041. * * 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`)
  56042. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56043. * * 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
  56044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56045. * * 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
  56046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56047. * @param name defines the name of the mesh
  56048. * @param options defines the options used to create the mesh
  56049. * @param scene defines the hosting scene
  56050. * @returns the icosahedron mesh
  56051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56052. */
  56053. static CreateIcoSphere(name: string, options: {
  56054. radius?: number;
  56055. radiusX?: number;
  56056. radiusY?: number;
  56057. radiusZ?: number;
  56058. flat?: boolean;
  56059. subdivisions?: number;
  56060. sideOrientation?: number;
  56061. frontUVs?: Vector4;
  56062. backUVs?: Vector4;
  56063. updatable?: boolean;
  56064. }, scene?: Nullable<Scene>): Mesh;
  56065. /**
  56066. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56067. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56068. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56069. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56070. * * 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
  56071. * * 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
  56072. * * 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
  56073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56074. * * 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
  56075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56076. * * 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
  56077. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56078. * * 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
  56079. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56081. * @param name defines the name of the mesh
  56082. * @param options defines the options used to create the mesh
  56083. * @param scene defines the hosting scene
  56084. * @returns the ribbon mesh
  56085. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56087. */
  56088. static CreateRibbon(name: string, options: {
  56089. pathArray: Vector3[][];
  56090. closeArray?: boolean;
  56091. closePath?: boolean;
  56092. offset?: number;
  56093. updatable?: boolean;
  56094. sideOrientation?: number;
  56095. frontUVs?: Vector4;
  56096. backUVs?: Vector4;
  56097. instance?: Mesh;
  56098. invertUV?: boolean;
  56099. uvs?: Vector2[];
  56100. colors?: Color4[];
  56101. }, scene?: Nullable<Scene>): Mesh;
  56102. /**
  56103. * Creates a cylinder or a cone mesh
  56104. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56105. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56106. * * 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.
  56107. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56108. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56109. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56110. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56111. * * 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).
  56112. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56113. * * 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).
  56114. * * 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
  56115. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56116. * * 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
  56117. * * 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.
  56118. * * If `enclose` is false, a ring surface is one element.
  56119. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56120. * * 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
  56121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56122. * * 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
  56123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56124. * @param name defines the name of the mesh
  56125. * @param options defines the options used to create the mesh
  56126. * @param scene defines the hosting scene
  56127. * @returns the cylinder mesh
  56128. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56129. */
  56130. static CreateCylinder(name: string, options: {
  56131. height?: number;
  56132. diameterTop?: number;
  56133. diameterBottom?: number;
  56134. diameter?: number;
  56135. tessellation?: number;
  56136. subdivisions?: number;
  56137. arc?: number;
  56138. faceColors?: Color4[];
  56139. faceUV?: Vector4[];
  56140. updatable?: boolean;
  56141. hasRings?: boolean;
  56142. enclose?: boolean;
  56143. cap?: number;
  56144. sideOrientation?: number;
  56145. frontUVs?: Vector4;
  56146. backUVs?: Vector4;
  56147. }, scene?: Nullable<Scene>): Mesh;
  56148. /**
  56149. * Creates a torus mesh
  56150. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56151. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56152. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56154. * * 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
  56155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56156. * @param name defines the name of the mesh
  56157. * @param options defines the options used to create the mesh
  56158. * @param scene defines the hosting scene
  56159. * @returns the torus mesh
  56160. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56161. */
  56162. static CreateTorus(name: string, options: {
  56163. diameter?: number;
  56164. thickness?: number;
  56165. tessellation?: number;
  56166. updatable?: boolean;
  56167. sideOrientation?: number;
  56168. frontUVs?: Vector4;
  56169. backUVs?: Vector4;
  56170. }, scene?: Nullable<Scene>): Mesh;
  56171. /**
  56172. * Creates a torus knot mesh
  56173. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56174. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56175. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56176. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56178. * * 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
  56179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56180. * @param name defines the name of the mesh
  56181. * @param options defines the options used to create the mesh
  56182. * @param scene defines the hosting scene
  56183. * @returns the torus knot mesh
  56184. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56185. */
  56186. static CreateTorusKnot(name: string, options: {
  56187. radius?: number;
  56188. tube?: number;
  56189. radialSegments?: number;
  56190. tubularSegments?: number;
  56191. p?: number;
  56192. q?: number;
  56193. updatable?: boolean;
  56194. sideOrientation?: number;
  56195. frontUVs?: Vector4;
  56196. backUVs?: Vector4;
  56197. }, scene?: Nullable<Scene>): Mesh;
  56198. /**
  56199. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56200. * * 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
  56201. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56202. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56203. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56204. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56205. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56206. * * 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
  56207. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56210. * @param name defines the name of the new line system
  56211. * @param options defines the options used to create the line system
  56212. * @param scene defines the hosting scene
  56213. * @returns a new line system mesh
  56214. */
  56215. static CreateLineSystem(name: string, options: {
  56216. lines: Vector3[][];
  56217. updatable?: boolean;
  56218. instance?: Nullable<LinesMesh>;
  56219. colors?: Nullable<Color4[][]>;
  56220. useVertexAlpha?: boolean;
  56221. }, scene: Nullable<Scene>): LinesMesh;
  56222. /**
  56223. * Creates a line mesh
  56224. * 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
  56225. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56226. * * The parameter `points` is an array successive Vector3
  56227. * * 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
  56228. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56229. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56230. * * When updating an instance, remember that only point positions can change, not the number of points
  56231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56233. * @param name defines the name of the new line system
  56234. * @param options defines the options used to create the line system
  56235. * @param scene defines the hosting scene
  56236. * @returns a new line mesh
  56237. */
  56238. static CreateLines(name: string, options: {
  56239. points: Vector3[];
  56240. updatable?: boolean;
  56241. instance?: Nullable<LinesMesh>;
  56242. colors?: Color4[];
  56243. useVertexAlpha?: boolean;
  56244. }, scene?: Nullable<Scene>): LinesMesh;
  56245. /**
  56246. * Creates a dashed line mesh
  56247. * * 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
  56248. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56249. * * The parameter `points` is an array successive Vector3
  56250. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56251. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56252. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56253. * * 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
  56254. * * When updating an instance, remember that only point positions can change, not the number of points
  56255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56256. * @param name defines the name of the mesh
  56257. * @param options defines the options used to create the mesh
  56258. * @param scene defines the hosting scene
  56259. * @returns the dashed line mesh
  56260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56261. */
  56262. static CreateDashedLines(name: string, options: {
  56263. points: Vector3[];
  56264. dashSize?: number;
  56265. gapSize?: number;
  56266. dashNb?: number;
  56267. updatable?: boolean;
  56268. instance?: LinesMesh;
  56269. }, scene?: Nullable<Scene>): LinesMesh;
  56270. /**
  56271. * 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.
  56272. * * 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.
  56273. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56274. * * 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.
  56275. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56276. * * 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
  56277. * * 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
  56278. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56280. * * 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
  56281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56283. * @param name defines the name of the mesh
  56284. * @param options defines the options used to create the mesh
  56285. * @param scene defines the hosting scene
  56286. * @returns the extruded shape mesh
  56287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56289. */
  56290. static ExtrudeShape(name: string, options: {
  56291. shape: Vector3[];
  56292. path: Vector3[];
  56293. scale?: number;
  56294. rotation?: number;
  56295. cap?: number;
  56296. updatable?: boolean;
  56297. sideOrientation?: number;
  56298. frontUVs?: Vector4;
  56299. backUVs?: Vector4;
  56300. instance?: Mesh;
  56301. invertUV?: boolean;
  56302. }, scene?: Nullable<Scene>): Mesh;
  56303. /**
  56304. * Creates an custom extruded shape mesh.
  56305. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56306. * * 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.
  56307. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56308. * * 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
  56309. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56310. * * 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
  56311. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56312. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56313. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56314. * * 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
  56315. * * 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
  56316. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56318. * * 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
  56319. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56321. * @param name defines the name of the mesh
  56322. * @param options defines the options used to create the mesh
  56323. * @param scene defines the hosting scene
  56324. * @returns the custom extruded shape mesh
  56325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56326. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56328. */
  56329. static ExtrudeShapeCustom(name: string, options: {
  56330. shape: Vector3[];
  56331. path: Vector3[];
  56332. scaleFunction?: any;
  56333. rotationFunction?: any;
  56334. ribbonCloseArray?: boolean;
  56335. ribbonClosePath?: boolean;
  56336. cap?: number;
  56337. updatable?: boolean;
  56338. sideOrientation?: number;
  56339. frontUVs?: Vector4;
  56340. backUVs?: Vector4;
  56341. instance?: Mesh;
  56342. invertUV?: boolean;
  56343. }, scene?: Nullable<Scene>): Mesh;
  56344. /**
  56345. * Creates lathe mesh.
  56346. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56347. * * 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
  56348. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56349. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56350. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56351. * * 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
  56352. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56353. * * 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
  56354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56355. * * 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
  56356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56358. * @param name defines the name of the mesh
  56359. * @param options defines the options used to create the mesh
  56360. * @param scene defines the hosting scene
  56361. * @returns the lathe mesh
  56362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56363. */
  56364. static CreateLathe(name: string, options: {
  56365. shape: Vector3[];
  56366. radius?: number;
  56367. tessellation?: number;
  56368. clip?: number;
  56369. arc?: number;
  56370. closed?: boolean;
  56371. updatable?: boolean;
  56372. sideOrientation?: number;
  56373. frontUVs?: Vector4;
  56374. backUVs?: Vector4;
  56375. cap?: number;
  56376. invertUV?: boolean;
  56377. }, scene?: Nullable<Scene>): Mesh;
  56378. /**
  56379. * Creates a tiled plane mesh
  56380. * * You can set a limited pattern arrangement with the tiles
  56381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56382. * * 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
  56383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56384. * @param name defines the name of the mesh
  56385. * @param options defines the options used to create the mesh
  56386. * @param scene defines the hosting scene
  56387. * @returns the plane mesh
  56388. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56389. */
  56390. static CreateTiledPlane(name: string, options: {
  56391. pattern?: number;
  56392. tileSize?: number;
  56393. tileWidth?: number;
  56394. tileHeight?: number;
  56395. size?: number;
  56396. width?: number;
  56397. height?: number;
  56398. alignHorizontal?: number;
  56399. alignVertical?: number;
  56400. sideOrientation?: number;
  56401. frontUVs?: Vector4;
  56402. backUVs?: Vector4;
  56403. updatable?: boolean;
  56404. }, scene?: Nullable<Scene>): Mesh;
  56405. /**
  56406. * Creates a plane mesh
  56407. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56408. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56409. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56411. * * 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
  56412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56413. * @param name defines the name of the mesh
  56414. * @param options defines the options used to create the mesh
  56415. * @param scene defines the hosting scene
  56416. * @returns the plane mesh
  56417. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56418. */
  56419. static CreatePlane(name: string, options: {
  56420. size?: number;
  56421. width?: number;
  56422. height?: number;
  56423. sideOrientation?: number;
  56424. frontUVs?: Vector4;
  56425. backUVs?: Vector4;
  56426. updatable?: boolean;
  56427. sourcePlane?: Plane;
  56428. }, scene?: Nullable<Scene>): Mesh;
  56429. /**
  56430. * Creates a ground mesh
  56431. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56432. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56434. * @param name defines the name of the mesh
  56435. * @param options defines the options used to create the mesh
  56436. * @param scene defines the hosting scene
  56437. * @returns the ground mesh
  56438. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56439. */
  56440. static CreateGround(name: string, options: {
  56441. width?: number;
  56442. height?: number;
  56443. subdivisions?: number;
  56444. subdivisionsX?: number;
  56445. subdivisionsY?: number;
  56446. updatable?: boolean;
  56447. }, scene?: Nullable<Scene>): Mesh;
  56448. /**
  56449. * Creates a tiled ground mesh
  56450. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56451. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56452. * * 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
  56453. * * 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
  56454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56455. * @param name defines the name of the mesh
  56456. * @param options defines the options used to create the mesh
  56457. * @param scene defines the hosting scene
  56458. * @returns the tiled ground mesh
  56459. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56460. */
  56461. static CreateTiledGround(name: string, options: {
  56462. xmin: number;
  56463. zmin: number;
  56464. xmax: number;
  56465. zmax: number;
  56466. subdivisions?: {
  56467. w: number;
  56468. h: number;
  56469. };
  56470. precision?: {
  56471. w: number;
  56472. h: number;
  56473. };
  56474. updatable?: boolean;
  56475. }, scene?: Nullable<Scene>): Mesh;
  56476. /**
  56477. * Creates a ground mesh from a height map
  56478. * * The parameter `url` sets the URL of the height map image resource.
  56479. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56480. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56481. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56482. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56483. * * 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.
  56484. * * 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).
  56485. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56487. * @param name defines the name of the mesh
  56488. * @param url defines the url to the height map
  56489. * @param options defines the options used to create the mesh
  56490. * @param scene defines the hosting scene
  56491. * @returns the ground mesh
  56492. * @see https://doc.babylonjs.com/babylon101/height_map
  56493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56494. */
  56495. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56496. width?: number;
  56497. height?: number;
  56498. subdivisions?: number;
  56499. minHeight?: number;
  56500. maxHeight?: number;
  56501. colorFilter?: Color3;
  56502. alphaFilter?: number;
  56503. updatable?: boolean;
  56504. onReady?: (mesh: GroundMesh) => void;
  56505. }, scene?: Nullable<Scene>): GroundMesh;
  56506. /**
  56507. * Creates a polygon mesh
  56508. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56509. * * 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
  56510. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56512. * * 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)
  56513. * * Remember you can only change the shape positions, not their number when updating a polygon
  56514. * @param name defines the name of the mesh
  56515. * @param options defines the options used to create the mesh
  56516. * @param scene defines the hosting scene
  56517. * @param earcutInjection can be used to inject your own earcut reference
  56518. * @returns the polygon mesh
  56519. */
  56520. static CreatePolygon(name: string, options: {
  56521. shape: Vector3[];
  56522. holes?: Vector3[][];
  56523. depth?: number;
  56524. faceUV?: Vector4[];
  56525. faceColors?: Color4[];
  56526. updatable?: boolean;
  56527. sideOrientation?: number;
  56528. frontUVs?: Vector4;
  56529. backUVs?: Vector4;
  56530. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56531. /**
  56532. * Creates an extruded polygon mesh, with depth in the Y direction.
  56533. * * 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)
  56534. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56535. * @param name defines the name of the mesh
  56536. * @param options defines the options used to create the mesh
  56537. * @param scene defines the hosting scene
  56538. * @param earcutInjection can be used to inject your own earcut reference
  56539. * @returns the polygon mesh
  56540. */
  56541. static ExtrudePolygon(name: string, options: {
  56542. shape: Vector3[];
  56543. holes?: Vector3[][];
  56544. depth?: number;
  56545. faceUV?: Vector4[];
  56546. faceColors?: Color4[];
  56547. updatable?: boolean;
  56548. sideOrientation?: number;
  56549. frontUVs?: Vector4;
  56550. backUVs?: Vector4;
  56551. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56552. /**
  56553. * Creates a tube mesh.
  56554. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56555. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56556. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56557. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56558. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56559. * * 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)
  56560. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56561. * * 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
  56562. * * 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
  56563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56564. * * 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
  56565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56567. * @param name defines the name of the mesh
  56568. * @param options defines the options used to create the mesh
  56569. * @param scene defines the hosting scene
  56570. * @returns the tube mesh
  56571. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56572. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56573. */
  56574. static CreateTube(name: string, options: {
  56575. path: Vector3[];
  56576. radius?: number;
  56577. tessellation?: number;
  56578. radiusFunction?: {
  56579. (i: number, distance: number): number;
  56580. };
  56581. cap?: number;
  56582. arc?: number;
  56583. updatable?: boolean;
  56584. sideOrientation?: number;
  56585. frontUVs?: Vector4;
  56586. backUVs?: Vector4;
  56587. instance?: Mesh;
  56588. invertUV?: boolean;
  56589. }, scene?: Nullable<Scene>): Mesh;
  56590. /**
  56591. * Creates a polyhedron mesh
  56592. * * 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
  56593. * * The parameter `size` (positive float, default 1) sets the polygon size
  56594. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56595. * * 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`
  56596. * * 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
  56597. * * 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)`)
  56598. * * 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
  56599. * * 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
  56600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56601. * * 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
  56602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56603. * @param name defines the name of the mesh
  56604. * @param options defines the options used to create the mesh
  56605. * @param scene defines the hosting scene
  56606. * @returns the polyhedron mesh
  56607. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56608. */
  56609. static CreatePolyhedron(name: string, options: {
  56610. type?: number;
  56611. size?: number;
  56612. sizeX?: number;
  56613. sizeY?: number;
  56614. sizeZ?: number;
  56615. custom?: any;
  56616. faceUV?: Vector4[];
  56617. faceColors?: Color4[];
  56618. flat?: boolean;
  56619. updatable?: boolean;
  56620. sideOrientation?: number;
  56621. frontUVs?: Vector4;
  56622. backUVs?: Vector4;
  56623. }, scene?: Nullable<Scene>): Mesh;
  56624. /**
  56625. * Creates a decal mesh.
  56626. * 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
  56627. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56628. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56629. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56630. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56631. * @param name defines the name of the mesh
  56632. * @param sourceMesh defines the mesh where the decal must be applied
  56633. * @param options defines the options used to create the mesh
  56634. * @param scene defines the hosting scene
  56635. * @returns the decal mesh
  56636. * @see https://doc.babylonjs.com/how_to/decals
  56637. */
  56638. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56639. position?: Vector3;
  56640. normal?: Vector3;
  56641. size?: Vector3;
  56642. angle?: number;
  56643. }): Mesh;
  56644. }
  56645. }
  56646. declare module BABYLON {
  56647. /**
  56648. * A simplifier interface for future simplification implementations
  56649. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56650. */
  56651. export interface ISimplifier {
  56652. /**
  56653. * Simplification of a given mesh according to the given settings.
  56654. * Since this requires computation, it is assumed that the function runs async.
  56655. * @param settings The settings of the simplification, including quality and distance
  56656. * @param successCallback A callback that will be called after the mesh was simplified.
  56657. * @param errorCallback in case of an error, this callback will be called. optional.
  56658. */
  56659. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56660. }
  56661. /**
  56662. * Expected simplification settings.
  56663. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56664. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56665. */
  56666. export interface ISimplificationSettings {
  56667. /**
  56668. * Gets or sets the expected quality
  56669. */
  56670. quality: number;
  56671. /**
  56672. * Gets or sets the distance when this optimized version should be used
  56673. */
  56674. distance: number;
  56675. /**
  56676. * Gets an already optimized mesh
  56677. */
  56678. optimizeMesh?: boolean;
  56679. }
  56680. /**
  56681. * Class used to specify simplification options
  56682. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56683. */
  56684. export class SimplificationSettings implements ISimplificationSettings {
  56685. /** expected quality */
  56686. quality: number;
  56687. /** distance when this optimized version should be used */
  56688. distance: number;
  56689. /** already optimized mesh */
  56690. optimizeMesh?: boolean | undefined;
  56691. /**
  56692. * Creates a SimplificationSettings
  56693. * @param quality expected quality
  56694. * @param distance distance when this optimized version should be used
  56695. * @param optimizeMesh already optimized mesh
  56696. */
  56697. constructor(
  56698. /** expected quality */
  56699. quality: number,
  56700. /** distance when this optimized version should be used */
  56701. distance: number,
  56702. /** already optimized mesh */
  56703. optimizeMesh?: boolean | undefined);
  56704. }
  56705. /**
  56706. * Interface used to define a simplification task
  56707. */
  56708. export interface ISimplificationTask {
  56709. /**
  56710. * Array of settings
  56711. */
  56712. settings: Array<ISimplificationSettings>;
  56713. /**
  56714. * Simplification type
  56715. */
  56716. simplificationType: SimplificationType;
  56717. /**
  56718. * Mesh to simplify
  56719. */
  56720. mesh: Mesh;
  56721. /**
  56722. * Callback called on success
  56723. */
  56724. successCallback?: () => void;
  56725. /**
  56726. * Defines if parallel processing can be used
  56727. */
  56728. parallelProcessing: boolean;
  56729. }
  56730. /**
  56731. * Queue used to order the simplification tasks
  56732. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56733. */
  56734. export class SimplificationQueue {
  56735. private _simplificationArray;
  56736. /**
  56737. * Gets a boolean indicating that the process is still running
  56738. */
  56739. running: boolean;
  56740. /**
  56741. * Creates a new queue
  56742. */
  56743. constructor();
  56744. /**
  56745. * Adds a new simplification task
  56746. * @param task defines a task to add
  56747. */
  56748. addTask(task: ISimplificationTask): void;
  56749. /**
  56750. * Execute next task
  56751. */
  56752. executeNext(): void;
  56753. /**
  56754. * Execute a simplification task
  56755. * @param task defines the task to run
  56756. */
  56757. runSimplification(task: ISimplificationTask): void;
  56758. private getSimplifier;
  56759. }
  56760. /**
  56761. * The implemented types of simplification
  56762. * At the moment only Quadratic Error Decimation is implemented
  56763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56764. */
  56765. export enum SimplificationType {
  56766. /** Quadratic error decimation */
  56767. QUADRATIC = 0
  56768. }
  56769. }
  56770. declare module BABYLON {
  56771. interface Scene {
  56772. /** @hidden (Backing field) */
  56773. _simplificationQueue: SimplificationQueue;
  56774. /**
  56775. * Gets or sets the simplification queue attached to the scene
  56776. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56777. */
  56778. simplificationQueue: SimplificationQueue;
  56779. }
  56780. interface Mesh {
  56781. /**
  56782. * Simplify the mesh according to the given array of settings.
  56783. * Function will return immediately and will simplify async
  56784. * @param settings a collection of simplification settings
  56785. * @param parallelProcessing should all levels calculate parallel or one after the other
  56786. * @param simplificationType the type of simplification to run
  56787. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56788. * @returns the current mesh
  56789. */
  56790. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56791. }
  56792. /**
  56793. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56794. * created in a scene
  56795. */
  56796. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56797. /**
  56798. * The component name helpfull to identify the component in the list of scene components.
  56799. */
  56800. readonly name: string;
  56801. /**
  56802. * The scene the component belongs to.
  56803. */
  56804. scene: Scene;
  56805. /**
  56806. * Creates a new instance of the component for the given scene
  56807. * @param scene Defines the scene to register the component in
  56808. */
  56809. constructor(scene: Scene);
  56810. /**
  56811. * Registers the component in a given scene
  56812. */
  56813. register(): void;
  56814. /**
  56815. * Rebuilds the elements related to this component in case of
  56816. * context lost for instance.
  56817. */
  56818. rebuild(): void;
  56819. /**
  56820. * Disposes the component and the associated ressources
  56821. */
  56822. dispose(): void;
  56823. private _beforeCameraUpdate;
  56824. }
  56825. }
  56826. declare module BABYLON {
  56827. /**
  56828. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56829. */
  56830. export interface INavigationEnginePlugin {
  56831. /**
  56832. * plugin name
  56833. */
  56834. name: string;
  56835. /**
  56836. * Creates a navigation mesh
  56837. * @param meshes array of all the geometry used to compute the navigatio mesh
  56838. * @param parameters bunch of parameters used to filter geometry
  56839. */
  56840. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56841. /**
  56842. * Create a navigation mesh debug mesh
  56843. * @param scene is where the mesh will be added
  56844. * @returns debug display mesh
  56845. */
  56846. createDebugNavMesh(scene: Scene): Mesh;
  56847. /**
  56848. * Get a navigation mesh constrained position, closest to the parameter position
  56849. * @param position world position
  56850. * @returns the closest point to position constrained by the navigation mesh
  56851. */
  56852. getClosestPoint(position: Vector3): Vector3;
  56853. /**
  56854. * Get a navigation mesh constrained position, within a particular radius
  56855. * @param position world position
  56856. * @param maxRadius the maximum distance to the constrained world position
  56857. * @returns the closest point to position constrained by the navigation mesh
  56858. */
  56859. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56860. /**
  56861. * Compute the final position from a segment made of destination-position
  56862. * @param position world position
  56863. * @param destination world position
  56864. * @returns the resulting point along the navmesh
  56865. */
  56866. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56867. /**
  56868. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56869. * @param start world position
  56870. * @param end world position
  56871. * @returns array containing world position composing the path
  56872. */
  56873. computePath(start: Vector3, end: Vector3): Vector3[];
  56874. /**
  56875. * If this plugin is supported
  56876. * @returns true if plugin is supported
  56877. */
  56878. isSupported(): boolean;
  56879. /**
  56880. * Create a new Crowd so you can add agents
  56881. * @param maxAgents the maximum agent count in the crowd
  56882. * @param maxAgentRadius the maximum radius an agent can have
  56883. * @param scene to attach the crowd to
  56884. * @returns the crowd you can add agents to
  56885. */
  56886. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56887. /**
  56888. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56889. * The queries will try to find a solution within those bounds
  56890. * default is (1,1,1)
  56891. * @param extent x,y,z value that define the extent around the queries point of reference
  56892. */
  56893. setDefaultQueryExtent(extent: Vector3): void;
  56894. /**
  56895. * Get the Bounding box extent specified by setDefaultQueryExtent
  56896. * @returns the box extent values
  56897. */
  56898. getDefaultQueryExtent(): Vector3;
  56899. /**
  56900. * Release all resources
  56901. */
  56902. dispose(): void;
  56903. }
  56904. /**
  56905. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56906. */
  56907. export interface ICrowd {
  56908. /**
  56909. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56910. * You can attach anything to that node. The node position is updated in the scene update tick.
  56911. * @param pos world position that will be constrained by the navigation mesh
  56912. * @param parameters agent parameters
  56913. * @param transform hooked to the agent that will be update by the scene
  56914. * @returns agent index
  56915. */
  56916. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56917. /**
  56918. * Returns the agent position in world space
  56919. * @param index agent index returned by addAgent
  56920. * @returns world space position
  56921. */
  56922. getAgentPosition(index: number): Vector3;
  56923. /**
  56924. * Gets the agent velocity in world space
  56925. * @param index agent index returned by addAgent
  56926. * @returns world space velocity
  56927. */
  56928. getAgentVelocity(index: number): Vector3;
  56929. /**
  56930. * remove a particular agent previously created
  56931. * @param index agent index returned by addAgent
  56932. */
  56933. removeAgent(index: number): void;
  56934. /**
  56935. * get the list of all agents attached to this crowd
  56936. * @returns list of agent indices
  56937. */
  56938. getAgents(): number[];
  56939. /**
  56940. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56941. * @param deltaTime in seconds
  56942. */
  56943. update(deltaTime: number): void;
  56944. /**
  56945. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56946. * @param index agent index returned by addAgent
  56947. * @param destination targeted world position
  56948. */
  56949. agentGoto(index: number, destination: Vector3): void;
  56950. /**
  56951. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56952. * The queries will try to find a solution within those bounds
  56953. * default is (1,1,1)
  56954. * @param extent x,y,z value that define the extent around the queries point of reference
  56955. */
  56956. setDefaultQueryExtent(extent: Vector3): void;
  56957. /**
  56958. * Get the Bounding box extent specified by setDefaultQueryExtent
  56959. * @returns the box extent values
  56960. */
  56961. getDefaultQueryExtent(): Vector3;
  56962. /**
  56963. * Release all resources
  56964. */
  56965. dispose(): void;
  56966. }
  56967. /**
  56968. * Configures an agent
  56969. */
  56970. export interface IAgentParameters {
  56971. /**
  56972. * Agent radius. [Limit: >= 0]
  56973. */
  56974. radius: number;
  56975. /**
  56976. * Agent height. [Limit: > 0]
  56977. */
  56978. height: number;
  56979. /**
  56980. * Maximum allowed acceleration. [Limit: >= 0]
  56981. */
  56982. maxAcceleration: number;
  56983. /**
  56984. * Maximum allowed speed. [Limit: >= 0]
  56985. */
  56986. maxSpeed: number;
  56987. /**
  56988. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56989. */
  56990. collisionQueryRange: number;
  56991. /**
  56992. * The path visibility optimization range. [Limit: > 0]
  56993. */
  56994. pathOptimizationRange: number;
  56995. /**
  56996. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56997. */
  56998. separationWeight: number;
  56999. }
  57000. /**
  57001. * Configures the navigation mesh creation
  57002. */
  57003. export interface INavMeshParameters {
  57004. /**
  57005. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57006. */
  57007. cs: number;
  57008. /**
  57009. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57010. */
  57011. ch: number;
  57012. /**
  57013. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57014. */
  57015. walkableSlopeAngle: number;
  57016. /**
  57017. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57018. * be considered walkable. [Limit: >= 3] [Units: vx]
  57019. */
  57020. walkableHeight: number;
  57021. /**
  57022. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57023. */
  57024. walkableClimb: number;
  57025. /**
  57026. * The distance to erode/shrink the walkable area of the heightfield away from
  57027. * obstructions. [Limit: >=0] [Units: vx]
  57028. */
  57029. walkableRadius: number;
  57030. /**
  57031. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57032. */
  57033. maxEdgeLen: number;
  57034. /**
  57035. * The maximum distance a simplfied contour's border edges should deviate
  57036. * the original raw contour. [Limit: >=0] [Units: vx]
  57037. */
  57038. maxSimplificationError: number;
  57039. /**
  57040. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57041. */
  57042. minRegionArea: number;
  57043. /**
  57044. * Any regions with a span count smaller than this value will, if possible,
  57045. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57046. */
  57047. mergeRegionArea: number;
  57048. /**
  57049. * The maximum number of vertices allowed for polygons generated during the
  57050. * contour to polygon conversion process. [Limit: >= 3]
  57051. */
  57052. maxVertsPerPoly: number;
  57053. /**
  57054. * Sets the sampling distance to use when generating the detail mesh.
  57055. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57056. */
  57057. detailSampleDist: number;
  57058. /**
  57059. * The maximum distance the detail mesh surface should deviate from heightfield
  57060. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57061. */
  57062. detailSampleMaxError: number;
  57063. }
  57064. }
  57065. declare module BABYLON {
  57066. /**
  57067. * RecastJS navigation plugin
  57068. */
  57069. export class RecastJSPlugin implements INavigationEnginePlugin {
  57070. /**
  57071. * Reference to the Recast library
  57072. */
  57073. bjsRECAST: any;
  57074. /**
  57075. * plugin name
  57076. */
  57077. name: string;
  57078. /**
  57079. * the first navmesh created. We might extend this to support multiple navmeshes
  57080. */
  57081. navMesh: any;
  57082. /**
  57083. * Initializes the recastJS plugin
  57084. * @param recastInjection can be used to inject your own recast reference
  57085. */
  57086. constructor(recastInjection?: any);
  57087. /**
  57088. * Creates a navigation mesh
  57089. * @param meshes array of all the geometry used to compute the navigatio mesh
  57090. * @param parameters bunch of parameters used to filter geometry
  57091. */
  57092. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57093. /**
  57094. * Create a navigation mesh debug mesh
  57095. * @param scene is where the mesh will be added
  57096. * @returns debug display mesh
  57097. */
  57098. createDebugNavMesh(scene: Scene): Mesh;
  57099. /**
  57100. * Get a navigation mesh constrained position, closest to the parameter position
  57101. * @param position world position
  57102. * @returns the closest point to position constrained by the navigation mesh
  57103. */
  57104. getClosestPoint(position: Vector3): Vector3;
  57105. /**
  57106. * Get a navigation mesh constrained position, within a particular radius
  57107. * @param position world position
  57108. * @param maxRadius the maximum distance to the constrained world position
  57109. * @returns the closest point to position constrained by the navigation mesh
  57110. */
  57111. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57112. /**
  57113. * Compute the final position from a segment made of destination-position
  57114. * @param position world position
  57115. * @param destination world position
  57116. * @returns the resulting point along the navmesh
  57117. */
  57118. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57119. /**
  57120. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57121. * @param start world position
  57122. * @param end world position
  57123. * @returns array containing world position composing the path
  57124. */
  57125. computePath(start: Vector3, end: Vector3): Vector3[];
  57126. /**
  57127. * Create a new Crowd so you can add agents
  57128. * @param maxAgents the maximum agent count in the crowd
  57129. * @param maxAgentRadius the maximum radius an agent can have
  57130. * @param scene to attach the crowd to
  57131. * @returns the crowd you can add agents to
  57132. */
  57133. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57134. /**
  57135. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57136. * The queries will try to find a solution within those bounds
  57137. * default is (1,1,1)
  57138. * @param extent x,y,z value that define the extent around the queries point of reference
  57139. */
  57140. setDefaultQueryExtent(extent: Vector3): void;
  57141. /**
  57142. * Get the Bounding box extent specified by setDefaultQueryExtent
  57143. * @returns the box extent values
  57144. */
  57145. getDefaultQueryExtent(): Vector3;
  57146. /**
  57147. * Disposes
  57148. */
  57149. dispose(): void;
  57150. /**
  57151. * If this plugin is supported
  57152. * @returns true if plugin is supported
  57153. */
  57154. isSupported(): boolean;
  57155. }
  57156. /**
  57157. * Recast detour crowd implementation
  57158. */
  57159. export class RecastJSCrowd implements ICrowd {
  57160. /**
  57161. * Recast/detour plugin
  57162. */
  57163. bjsRECASTPlugin: RecastJSPlugin;
  57164. /**
  57165. * Link to the detour crowd
  57166. */
  57167. recastCrowd: any;
  57168. /**
  57169. * One transform per agent
  57170. */
  57171. transforms: TransformNode[];
  57172. /**
  57173. * All agents created
  57174. */
  57175. agents: number[];
  57176. /**
  57177. * Link to the scene is kept to unregister the crowd from the scene
  57178. */
  57179. private _scene;
  57180. /**
  57181. * Observer for crowd updates
  57182. */
  57183. private _onBeforeAnimationsObserver;
  57184. /**
  57185. * Constructor
  57186. * @param plugin recastJS plugin
  57187. * @param maxAgents the maximum agent count in the crowd
  57188. * @param maxAgentRadius the maximum radius an agent can have
  57189. * @param scene to attach the crowd to
  57190. * @returns the crowd you can add agents to
  57191. */
  57192. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57193. /**
  57194. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57195. * You can attach anything to that node. The node position is updated in the scene update tick.
  57196. * @param pos world position that will be constrained by the navigation mesh
  57197. * @param parameters agent parameters
  57198. * @param transform hooked to the agent that will be update by the scene
  57199. * @returns agent index
  57200. */
  57201. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57202. /**
  57203. * Returns the agent position in world space
  57204. * @param index agent index returned by addAgent
  57205. * @returns world space position
  57206. */
  57207. getAgentPosition(index: number): Vector3;
  57208. /**
  57209. * Returns the agent velocity in world space
  57210. * @param index agent index returned by addAgent
  57211. * @returns world space velocity
  57212. */
  57213. getAgentVelocity(index: number): Vector3;
  57214. /**
  57215. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57216. * @param index agent index returned by addAgent
  57217. * @param destination targeted world position
  57218. */
  57219. agentGoto(index: number, destination: Vector3): void;
  57220. /**
  57221. * remove a particular agent previously created
  57222. * @param index agent index returned by addAgent
  57223. */
  57224. removeAgent(index: number): void;
  57225. /**
  57226. * get the list of all agents attached to this crowd
  57227. * @returns list of agent indices
  57228. */
  57229. getAgents(): number[];
  57230. /**
  57231. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57232. * @param deltaTime in seconds
  57233. */
  57234. update(deltaTime: number): void;
  57235. /**
  57236. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57237. * The queries will try to find a solution within those bounds
  57238. * default is (1,1,1)
  57239. * @param extent x,y,z value that define the extent around the queries point of reference
  57240. */
  57241. setDefaultQueryExtent(extent: Vector3): void;
  57242. /**
  57243. * Get the Bounding box extent specified by setDefaultQueryExtent
  57244. * @returns the box extent values
  57245. */
  57246. getDefaultQueryExtent(): Vector3;
  57247. /**
  57248. * Release all resources
  57249. */
  57250. dispose(): void;
  57251. }
  57252. }
  57253. declare module BABYLON {
  57254. /**
  57255. * Class used to enable access to IndexedDB
  57256. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57257. */
  57258. export class Database implements IOfflineProvider {
  57259. private _callbackManifestChecked;
  57260. private _currentSceneUrl;
  57261. private _db;
  57262. private _enableSceneOffline;
  57263. private _enableTexturesOffline;
  57264. private _manifestVersionFound;
  57265. private _mustUpdateRessources;
  57266. private _hasReachedQuota;
  57267. private _isSupported;
  57268. private _idbFactory;
  57269. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57270. private static IsUASupportingBlobStorage;
  57271. /**
  57272. * Gets a boolean indicating if Database storate is enabled (off by default)
  57273. */
  57274. static IDBStorageEnabled: boolean;
  57275. /**
  57276. * Gets a boolean indicating if scene must be saved in the database
  57277. */
  57278. readonly enableSceneOffline: boolean;
  57279. /**
  57280. * Gets a boolean indicating if textures must be saved in the database
  57281. */
  57282. readonly enableTexturesOffline: boolean;
  57283. /**
  57284. * Creates a new Database
  57285. * @param urlToScene defines the url to load the scene
  57286. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57287. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57288. */
  57289. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57290. private static _ParseURL;
  57291. private static _ReturnFullUrlLocation;
  57292. private _checkManifestFile;
  57293. /**
  57294. * Open the database and make it available
  57295. * @param successCallback defines the callback to call on success
  57296. * @param errorCallback defines the callback to call on error
  57297. */
  57298. open(successCallback: () => void, errorCallback: () => void): void;
  57299. /**
  57300. * Loads an image from the database
  57301. * @param url defines the url to load from
  57302. * @param image defines the target DOM image
  57303. */
  57304. loadImage(url: string, image: HTMLImageElement): void;
  57305. private _loadImageFromDBAsync;
  57306. private _saveImageIntoDBAsync;
  57307. private _checkVersionFromDB;
  57308. private _loadVersionFromDBAsync;
  57309. private _saveVersionIntoDBAsync;
  57310. /**
  57311. * Loads a file from database
  57312. * @param url defines the URL to load from
  57313. * @param sceneLoaded defines a callback to call on success
  57314. * @param progressCallBack defines a callback to call when progress changed
  57315. * @param errorCallback defines a callback to call on error
  57316. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57317. */
  57318. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57319. private _loadFileAsync;
  57320. private _saveFileAsync;
  57321. /**
  57322. * Validates if xhr data is correct
  57323. * @param xhr defines the request to validate
  57324. * @param dataType defines the expected data type
  57325. * @returns true if data is correct
  57326. */
  57327. private static _ValidateXHRData;
  57328. }
  57329. }
  57330. declare module BABYLON {
  57331. /** @hidden */
  57332. export var gpuUpdateParticlesPixelShader: {
  57333. name: string;
  57334. shader: string;
  57335. };
  57336. }
  57337. declare module BABYLON {
  57338. /** @hidden */
  57339. export var gpuUpdateParticlesVertexShader: {
  57340. name: string;
  57341. shader: string;
  57342. };
  57343. }
  57344. declare module BABYLON {
  57345. /** @hidden */
  57346. export var clipPlaneFragmentDeclaration2: {
  57347. name: string;
  57348. shader: string;
  57349. };
  57350. }
  57351. declare module BABYLON {
  57352. /** @hidden */
  57353. export var gpuRenderParticlesPixelShader: {
  57354. name: string;
  57355. shader: string;
  57356. };
  57357. }
  57358. declare module BABYLON {
  57359. /** @hidden */
  57360. export var clipPlaneVertexDeclaration2: {
  57361. name: string;
  57362. shader: string;
  57363. };
  57364. }
  57365. declare module BABYLON {
  57366. /** @hidden */
  57367. export var gpuRenderParticlesVertexShader: {
  57368. name: string;
  57369. shader: string;
  57370. };
  57371. }
  57372. declare module BABYLON {
  57373. /**
  57374. * This represents a GPU particle system in Babylon
  57375. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57376. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57377. */
  57378. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57379. /**
  57380. * The layer mask we are rendering the particles through.
  57381. */
  57382. layerMask: number;
  57383. private _capacity;
  57384. private _activeCount;
  57385. private _currentActiveCount;
  57386. private _accumulatedCount;
  57387. private _renderEffect;
  57388. private _updateEffect;
  57389. private _buffer0;
  57390. private _buffer1;
  57391. private _spriteBuffer;
  57392. private _updateVAO;
  57393. private _renderVAO;
  57394. private _targetIndex;
  57395. private _sourceBuffer;
  57396. private _targetBuffer;
  57397. private _engine;
  57398. private _currentRenderId;
  57399. private _started;
  57400. private _stopped;
  57401. private _timeDelta;
  57402. private _randomTexture;
  57403. private _randomTexture2;
  57404. private _attributesStrideSize;
  57405. private _updateEffectOptions;
  57406. private _randomTextureSize;
  57407. private _actualFrame;
  57408. private readonly _rawTextureWidth;
  57409. /**
  57410. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57411. */
  57412. static readonly IsSupported: boolean;
  57413. /**
  57414. * An event triggered when the system is disposed.
  57415. */
  57416. onDisposeObservable: Observable<GPUParticleSystem>;
  57417. /**
  57418. * Gets the maximum number of particles active at the same time.
  57419. * @returns The max number of active particles.
  57420. */
  57421. getCapacity(): number;
  57422. /**
  57423. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57424. * to override the particles.
  57425. */
  57426. forceDepthWrite: boolean;
  57427. /**
  57428. * Gets or set the number of active particles
  57429. */
  57430. activeParticleCount: number;
  57431. private _preWarmDone;
  57432. /**
  57433. * Is this system ready to be used/rendered
  57434. * @return true if the system is ready
  57435. */
  57436. isReady(): boolean;
  57437. /**
  57438. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57439. * @returns True if it has been started, otherwise false.
  57440. */
  57441. isStarted(): boolean;
  57442. /**
  57443. * Starts the particle system and begins to emit
  57444. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57445. */
  57446. start(delay?: number): void;
  57447. /**
  57448. * Stops the particle system.
  57449. */
  57450. stop(): void;
  57451. /**
  57452. * Remove all active particles
  57453. */
  57454. reset(): void;
  57455. /**
  57456. * Returns the string "GPUParticleSystem"
  57457. * @returns a string containing the class name
  57458. */
  57459. getClassName(): string;
  57460. private _colorGradientsTexture;
  57461. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57462. /**
  57463. * Adds a new color gradient
  57464. * @param gradient defines the gradient to use (between 0 and 1)
  57465. * @param color1 defines the color to affect to the specified gradient
  57466. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57467. * @returns the current particle system
  57468. */
  57469. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57470. /**
  57471. * Remove a specific color gradient
  57472. * @param gradient defines the gradient to remove
  57473. * @returns the current particle system
  57474. */
  57475. removeColorGradient(gradient: number): GPUParticleSystem;
  57476. private _angularSpeedGradientsTexture;
  57477. private _sizeGradientsTexture;
  57478. private _velocityGradientsTexture;
  57479. private _limitVelocityGradientsTexture;
  57480. private _dragGradientsTexture;
  57481. private _addFactorGradient;
  57482. /**
  57483. * Adds a new size gradient
  57484. * @param gradient defines the gradient to use (between 0 and 1)
  57485. * @param factor defines the size factor to affect to the specified gradient
  57486. * @returns the current particle system
  57487. */
  57488. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57489. /**
  57490. * Remove a specific size gradient
  57491. * @param gradient defines the gradient to remove
  57492. * @returns the current particle system
  57493. */
  57494. removeSizeGradient(gradient: number): GPUParticleSystem;
  57495. /**
  57496. * Adds a new angular speed gradient
  57497. * @param gradient defines the gradient to use (between 0 and 1)
  57498. * @param factor defines the angular speed to affect to the specified gradient
  57499. * @returns the current particle system
  57500. */
  57501. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57502. /**
  57503. * Remove a specific angular speed gradient
  57504. * @param gradient defines the gradient to remove
  57505. * @returns the current particle system
  57506. */
  57507. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57508. /**
  57509. * Adds a new velocity gradient
  57510. * @param gradient defines the gradient to use (between 0 and 1)
  57511. * @param factor defines the velocity to affect to the specified gradient
  57512. * @returns the current particle system
  57513. */
  57514. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57515. /**
  57516. * Remove a specific velocity gradient
  57517. * @param gradient defines the gradient to remove
  57518. * @returns the current particle system
  57519. */
  57520. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57521. /**
  57522. * Adds a new limit velocity gradient
  57523. * @param gradient defines the gradient to use (between 0 and 1)
  57524. * @param factor defines the limit velocity value to affect to the specified gradient
  57525. * @returns the current particle system
  57526. */
  57527. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57528. /**
  57529. * Remove a specific limit velocity gradient
  57530. * @param gradient defines the gradient to remove
  57531. * @returns the current particle system
  57532. */
  57533. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57534. /**
  57535. * Adds a new drag gradient
  57536. * @param gradient defines the gradient to use (between 0 and 1)
  57537. * @param factor defines the drag value to affect to the specified gradient
  57538. * @returns the current particle system
  57539. */
  57540. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57541. /**
  57542. * Remove a specific drag gradient
  57543. * @param gradient defines the gradient to remove
  57544. * @returns the current particle system
  57545. */
  57546. removeDragGradient(gradient: number): GPUParticleSystem;
  57547. /**
  57548. * Not supported by GPUParticleSystem
  57549. * @param gradient defines the gradient to use (between 0 and 1)
  57550. * @param factor defines the emit rate value to affect to the specified gradient
  57551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57552. * @returns the current particle system
  57553. */
  57554. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57555. /**
  57556. * Not supported by GPUParticleSystem
  57557. * @param gradient defines the gradient to remove
  57558. * @returns the current particle system
  57559. */
  57560. removeEmitRateGradient(gradient: number): IParticleSystem;
  57561. /**
  57562. * Not supported by GPUParticleSystem
  57563. * @param gradient defines the gradient to use (between 0 and 1)
  57564. * @param factor defines the start size value to affect to the specified gradient
  57565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57566. * @returns the current particle system
  57567. */
  57568. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57569. /**
  57570. * Not supported by GPUParticleSystem
  57571. * @param gradient defines the gradient to remove
  57572. * @returns the current particle system
  57573. */
  57574. removeStartSizeGradient(gradient: number): IParticleSystem;
  57575. /**
  57576. * Not supported by GPUParticleSystem
  57577. * @param gradient defines the gradient to use (between 0 and 1)
  57578. * @param min defines the color remap minimal range
  57579. * @param max defines the color remap maximal range
  57580. * @returns the current particle system
  57581. */
  57582. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57583. /**
  57584. * Not supported by GPUParticleSystem
  57585. * @param gradient defines the gradient to remove
  57586. * @returns the current particle system
  57587. */
  57588. removeColorRemapGradient(): IParticleSystem;
  57589. /**
  57590. * Not supported by GPUParticleSystem
  57591. * @param gradient defines the gradient to use (between 0 and 1)
  57592. * @param min defines the alpha remap minimal range
  57593. * @param max defines the alpha remap maximal range
  57594. * @returns the current particle system
  57595. */
  57596. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57597. /**
  57598. * Not supported by GPUParticleSystem
  57599. * @param gradient defines the gradient to remove
  57600. * @returns the current particle system
  57601. */
  57602. removeAlphaRemapGradient(): IParticleSystem;
  57603. /**
  57604. * Not supported by GPUParticleSystem
  57605. * @param gradient defines the gradient to use (between 0 and 1)
  57606. * @param color defines the color to affect to the specified gradient
  57607. * @returns the current particle system
  57608. */
  57609. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57610. /**
  57611. * Not supported by GPUParticleSystem
  57612. * @param gradient defines the gradient to remove
  57613. * @returns the current particle system
  57614. */
  57615. removeRampGradient(): IParticleSystem;
  57616. /**
  57617. * Not supported by GPUParticleSystem
  57618. * @returns the list of ramp gradients
  57619. */
  57620. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57621. /**
  57622. * Not supported by GPUParticleSystem
  57623. * Gets or sets a boolean indicating that ramp gradients must be used
  57624. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57625. */
  57626. useRampGradients: boolean;
  57627. /**
  57628. * Not supported by GPUParticleSystem
  57629. * @param gradient defines the gradient to use (between 0 and 1)
  57630. * @param factor defines the life time factor to affect to the specified gradient
  57631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57632. * @returns the current particle system
  57633. */
  57634. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57635. /**
  57636. * Not supported by GPUParticleSystem
  57637. * @param gradient defines the gradient to remove
  57638. * @returns the current particle system
  57639. */
  57640. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57641. /**
  57642. * Instantiates a GPU particle system.
  57643. * 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.
  57644. * @param name The name of the particle system
  57645. * @param options The options used to create the system
  57646. * @param scene The scene the particle system belongs to
  57647. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57648. */
  57649. constructor(name: string, options: Partial<{
  57650. capacity: number;
  57651. randomTextureSize: number;
  57652. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57653. protected _reset(): void;
  57654. private _createUpdateVAO;
  57655. private _createRenderVAO;
  57656. private _initialize;
  57657. /** @hidden */
  57658. _recreateUpdateEffect(): void;
  57659. /** @hidden */
  57660. _recreateRenderEffect(): void;
  57661. /**
  57662. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57663. * @param preWarm defines if we are in the pre-warmimg phase
  57664. */
  57665. animate(preWarm?: boolean): void;
  57666. private _createFactorGradientTexture;
  57667. private _createSizeGradientTexture;
  57668. private _createAngularSpeedGradientTexture;
  57669. private _createVelocityGradientTexture;
  57670. private _createLimitVelocityGradientTexture;
  57671. private _createDragGradientTexture;
  57672. private _createColorGradientTexture;
  57673. /**
  57674. * Renders the particle system in its current state
  57675. * @param preWarm defines if the system should only update the particles but not render them
  57676. * @returns the current number of particles
  57677. */
  57678. render(preWarm?: boolean): number;
  57679. /**
  57680. * Rebuilds the particle system
  57681. */
  57682. rebuild(): void;
  57683. private _releaseBuffers;
  57684. private _releaseVAOs;
  57685. /**
  57686. * Disposes the particle system and free the associated resources
  57687. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57688. */
  57689. dispose(disposeTexture?: boolean): void;
  57690. /**
  57691. * Clones the particle system.
  57692. * @param name The name of the cloned object
  57693. * @param newEmitter The new emitter to use
  57694. * @returns the cloned particle system
  57695. */
  57696. clone(name: string, newEmitter: any): GPUParticleSystem;
  57697. /**
  57698. * Serializes the particle system to a JSON object.
  57699. * @returns the JSON object
  57700. */
  57701. serialize(): any;
  57702. /**
  57703. * Parses a JSON object to create a GPU particle system.
  57704. * @param parsedParticleSystem The JSON object to parse
  57705. * @param scene The scene to create the particle system in
  57706. * @param rootUrl The root url to use to load external dependencies like texture
  57707. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57708. * @returns the parsed GPU particle system
  57709. */
  57710. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57711. }
  57712. }
  57713. declare module BABYLON {
  57714. /**
  57715. * Represents a set of particle systems working together to create a specific effect
  57716. */
  57717. export class ParticleSystemSet implements IDisposable {
  57718. private _emitterCreationOptions;
  57719. private _emitterNode;
  57720. /**
  57721. * Gets the particle system list
  57722. */
  57723. systems: IParticleSystem[];
  57724. /**
  57725. * Gets the emitter node used with this set
  57726. */
  57727. readonly emitterNode: Nullable<TransformNode>;
  57728. /**
  57729. * Creates a new emitter mesh as a sphere
  57730. * @param options defines the options used to create the sphere
  57731. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57732. * @param scene defines the hosting scene
  57733. */
  57734. setEmitterAsSphere(options: {
  57735. diameter: number;
  57736. segments: number;
  57737. color: Color3;
  57738. }, renderingGroupId: number, scene: Scene): void;
  57739. /**
  57740. * Starts all particle systems of the set
  57741. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57742. */
  57743. start(emitter?: AbstractMesh): void;
  57744. /**
  57745. * Release all associated resources
  57746. */
  57747. dispose(): void;
  57748. /**
  57749. * Serialize the set into a JSON compatible object
  57750. * @returns a JSON compatible representation of the set
  57751. */
  57752. serialize(): any;
  57753. /**
  57754. * Parse a new ParticleSystemSet from a serialized source
  57755. * @param data defines a JSON compatible representation of the set
  57756. * @param scene defines the hosting scene
  57757. * @param gpu defines if we want GPU particles or CPU particles
  57758. * @returns a new ParticleSystemSet
  57759. */
  57760. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57761. }
  57762. }
  57763. declare module BABYLON {
  57764. /**
  57765. * This class is made for on one-liner static method to help creating particle system set.
  57766. */
  57767. export class ParticleHelper {
  57768. /**
  57769. * Gets or sets base Assets URL
  57770. */
  57771. static BaseAssetsUrl: string;
  57772. /**
  57773. * Create a default particle system that you can tweak
  57774. * @param emitter defines the emitter to use
  57775. * @param capacity defines the system capacity (default is 500 particles)
  57776. * @param scene defines the hosting scene
  57777. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57778. * @returns the new Particle system
  57779. */
  57780. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57781. /**
  57782. * This is the main static method (one-liner) of this helper to create different particle systems
  57783. * @param type This string represents the type to the particle system to create
  57784. * @param scene The scene where the particle system should live
  57785. * @param gpu If the system will use gpu
  57786. * @returns the ParticleSystemSet created
  57787. */
  57788. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57789. /**
  57790. * Static function used to export a particle system to a ParticleSystemSet variable.
  57791. * Please note that the emitter shape is not exported
  57792. * @param systems defines the particle systems to export
  57793. * @returns the created particle system set
  57794. */
  57795. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57796. }
  57797. }
  57798. declare module BABYLON {
  57799. interface Engine {
  57800. /**
  57801. * Create an effect to use with particle systems.
  57802. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57803. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57804. * @param uniformsNames defines a list of attribute names
  57805. * @param samplers defines an array of string used to represent textures
  57806. * @param defines defines the string containing the defines to use to compile the shaders
  57807. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57808. * @param onCompiled defines a function to call when the effect creation is successful
  57809. * @param onError defines a function to call when the effect creation has failed
  57810. * @returns the new Effect
  57811. */
  57812. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57813. }
  57814. interface Mesh {
  57815. /**
  57816. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57817. * @returns an array of IParticleSystem
  57818. */
  57819. getEmittedParticleSystems(): IParticleSystem[];
  57820. /**
  57821. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57822. * @returns an array of IParticleSystem
  57823. */
  57824. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57825. }
  57826. /**
  57827. * @hidden
  57828. */
  57829. export var _IDoNeedToBeInTheBuild: number;
  57830. }
  57831. declare module BABYLON {
  57832. interface Scene {
  57833. /** @hidden (Backing field) */
  57834. _physicsEngine: Nullable<IPhysicsEngine>;
  57835. /**
  57836. * Gets the current physics engine
  57837. * @returns a IPhysicsEngine or null if none attached
  57838. */
  57839. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57840. /**
  57841. * Enables physics to the current scene
  57842. * @param gravity defines the scene's gravity for the physics engine
  57843. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57844. * @return a boolean indicating if the physics engine was initialized
  57845. */
  57846. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57847. /**
  57848. * Disables and disposes the physics engine associated with the scene
  57849. */
  57850. disablePhysicsEngine(): void;
  57851. /**
  57852. * Gets a boolean indicating if there is an active physics engine
  57853. * @returns a boolean indicating if there is an active physics engine
  57854. */
  57855. isPhysicsEnabled(): boolean;
  57856. /**
  57857. * Deletes a physics compound impostor
  57858. * @param compound defines the compound to delete
  57859. */
  57860. deleteCompoundImpostor(compound: any): void;
  57861. /**
  57862. * An event triggered when physic simulation is about to be run
  57863. */
  57864. onBeforePhysicsObservable: Observable<Scene>;
  57865. /**
  57866. * An event triggered when physic simulation has been done
  57867. */
  57868. onAfterPhysicsObservable: Observable<Scene>;
  57869. }
  57870. interface AbstractMesh {
  57871. /** @hidden */
  57872. _physicsImpostor: Nullable<PhysicsImpostor>;
  57873. /**
  57874. * Gets or sets impostor used for physic simulation
  57875. * @see http://doc.babylonjs.com/features/physics_engine
  57876. */
  57877. physicsImpostor: Nullable<PhysicsImpostor>;
  57878. /**
  57879. * Gets the current physics impostor
  57880. * @see http://doc.babylonjs.com/features/physics_engine
  57881. * @returns a physics impostor or null
  57882. */
  57883. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57884. /** Apply a physic impulse to the mesh
  57885. * @param force defines the force to apply
  57886. * @param contactPoint defines where to apply the force
  57887. * @returns the current mesh
  57888. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57889. */
  57890. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57891. /**
  57892. * Creates a physic joint between two meshes
  57893. * @param otherMesh defines the other mesh to use
  57894. * @param pivot1 defines the pivot to use on this mesh
  57895. * @param pivot2 defines the pivot to use on the other mesh
  57896. * @param options defines additional options (can be plugin dependent)
  57897. * @returns the current mesh
  57898. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57899. */
  57900. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57901. /** @hidden */
  57902. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57903. }
  57904. /**
  57905. * Defines the physics engine scene component responsible to manage a physics engine
  57906. */
  57907. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57908. /**
  57909. * The component name helpful to identify the component in the list of scene components.
  57910. */
  57911. readonly name: string;
  57912. /**
  57913. * The scene the component belongs to.
  57914. */
  57915. scene: Scene;
  57916. /**
  57917. * Creates a new instance of the component for the given scene
  57918. * @param scene Defines the scene to register the component in
  57919. */
  57920. constructor(scene: Scene);
  57921. /**
  57922. * Registers the component in a given scene
  57923. */
  57924. register(): void;
  57925. /**
  57926. * Rebuilds the elements related to this component in case of
  57927. * context lost for instance.
  57928. */
  57929. rebuild(): void;
  57930. /**
  57931. * Disposes the component and the associated ressources
  57932. */
  57933. dispose(): void;
  57934. }
  57935. }
  57936. declare module BABYLON {
  57937. /**
  57938. * A helper for physics simulations
  57939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57940. */
  57941. export class PhysicsHelper {
  57942. private _scene;
  57943. private _physicsEngine;
  57944. /**
  57945. * Initializes the Physics helper
  57946. * @param scene Babylon.js scene
  57947. */
  57948. constructor(scene: Scene);
  57949. /**
  57950. * Applies a radial explosion impulse
  57951. * @param origin the origin of the explosion
  57952. * @param radiusOrEventOptions the radius or the options of radial explosion
  57953. * @param strength the explosion strength
  57954. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57955. * @returns A physics radial explosion event, or null
  57956. */
  57957. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57958. /**
  57959. * Applies a radial explosion force
  57960. * @param origin the origin of the explosion
  57961. * @param radiusOrEventOptions the radius or the options of radial explosion
  57962. * @param strength the explosion strength
  57963. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57964. * @returns A physics radial explosion event, or null
  57965. */
  57966. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57967. /**
  57968. * Creates a gravitational field
  57969. * @param origin the origin of the explosion
  57970. * @param radiusOrEventOptions the radius or the options of radial explosion
  57971. * @param strength the explosion strength
  57972. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57973. * @returns A physics gravitational field event, or null
  57974. */
  57975. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57976. /**
  57977. * Creates a physics updraft event
  57978. * @param origin the origin of the updraft
  57979. * @param radiusOrEventOptions the radius or the options of the updraft
  57980. * @param strength the strength of the updraft
  57981. * @param height the height of the updraft
  57982. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57983. * @returns A physics updraft event, or null
  57984. */
  57985. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57986. /**
  57987. * Creates a physics vortex event
  57988. * @param origin the of the vortex
  57989. * @param radiusOrEventOptions the radius or the options of the vortex
  57990. * @param strength the strength of the vortex
  57991. * @param height the height of the vortex
  57992. * @returns a Physics vortex event, or null
  57993. * A physics vortex event or null
  57994. */
  57995. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57996. }
  57997. /**
  57998. * Represents a physics radial explosion event
  57999. */
  58000. class PhysicsRadialExplosionEvent {
  58001. private _scene;
  58002. private _options;
  58003. private _sphere;
  58004. private _dataFetched;
  58005. /**
  58006. * Initializes a radial explosioin event
  58007. * @param _scene BabylonJS scene
  58008. * @param _options The options for the vortex event
  58009. */
  58010. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58011. /**
  58012. * Returns the data related to the radial explosion event (sphere).
  58013. * @returns The radial explosion event data
  58014. */
  58015. getData(): PhysicsRadialExplosionEventData;
  58016. /**
  58017. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58018. * @param impostor A physics imposter
  58019. * @param origin the origin of the explosion
  58020. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58021. */
  58022. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58023. /**
  58024. * Triggers affecterd impostors callbacks
  58025. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58026. */
  58027. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58028. /**
  58029. * Disposes the sphere.
  58030. * @param force Specifies if the sphere should be disposed by force
  58031. */
  58032. dispose(force?: boolean): void;
  58033. /*** Helpers ***/
  58034. private _prepareSphere;
  58035. private _intersectsWithSphere;
  58036. }
  58037. /**
  58038. * Represents a gravitational field event
  58039. */
  58040. class PhysicsGravitationalFieldEvent {
  58041. private _physicsHelper;
  58042. private _scene;
  58043. private _origin;
  58044. private _options;
  58045. private _tickCallback;
  58046. private _sphere;
  58047. private _dataFetched;
  58048. /**
  58049. * Initializes the physics gravitational field event
  58050. * @param _physicsHelper A physics helper
  58051. * @param _scene BabylonJS scene
  58052. * @param _origin The origin position of the gravitational field event
  58053. * @param _options The options for the vortex event
  58054. */
  58055. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58056. /**
  58057. * Returns the data related to the gravitational field event (sphere).
  58058. * @returns A gravitational field event
  58059. */
  58060. getData(): PhysicsGravitationalFieldEventData;
  58061. /**
  58062. * Enables the gravitational field.
  58063. */
  58064. enable(): void;
  58065. /**
  58066. * Disables the gravitational field.
  58067. */
  58068. disable(): void;
  58069. /**
  58070. * Disposes the sphere.
  58071. * @param force The force to dispose from the gravitational field event
  58072. */
  58073. dispose(force?: boolean): void;
  58074. private _tick;
  58075. }
  58076. /**
  58077. * Represents a physics updraft event
  58078. */
  58079. class PhysicsUpdraftEvent {
  58080. private _scene;
  58081. private _origin;
  58082. private _options;
  58083. private _physicsEngine;
  58084. private _originTop;
  58085. private _originDirection;
  58086. private _tickCallback;
  58087. private _cylinder;
  58088. private _cylinderPosition;
  58089. private _dataFetched;
  58090. /**
  58091. * Initializes the physics updraft event
  58092. * @param _scene BabylonJS scene
  58093. * @param _origin The origin position of the updraft
  58094. * @param _options The options for the updraft event
  58095. */
  58096. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58097. /**
  58098. * Returns the data related to the updraft event (cylinder).
  58099. * @returns A physics updraft event
  58100. */
  58101. getData(): PhysicsUpdraftEventData;
  58102. /**
  58103. * Enables the updraft.
  58104. */
  58105. enable(): void;
  58106. /**
  58107. * Disables the updraft.
  58108. */
  58109. disable(): void;
  58110. /**
  58111. * Disposes the cylinder.
  58112. * @param force Specifies if the updraft should be disposed by force
  58113. */
  58114. dispose(force?: boolean): void;
  58115. private getImpostorHitData;
  58116. private _tick;
  58117. /*** Helpers ***/
  58118. private _prepareCylinder;
  58119. private _intersectsWithCylinder;
  58120. }
  58121. /**
  58122. * Represents a physics vortex event
  58123. */
  58124. class PhysicsVortexEvent {
  58125. private _scene;
  58126. private _origin;
  58127. private _options;
  58128. private _physicsEngine;
  58129. private _originTop;
  58130. private _tickCallback;
  58131. private _cylinder;
  58132. private _cylinderPosition;
  58133. private _dataFetched;
  58134. /**
  58135. * Initializes the physics vortex event
  58136. * @param _scene The BabylonJS scene
  58137. * @param _origin The origin position of the vortex
  58138. * @param _options The options for the vortex event
  58139. */
  58140. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58141. /**
  58142. * Returns the data related to the vortex event (cylinder).
  58143. * @returns The physics vortex event data
  58144. */
  58145. getData(): PhysicsVortexEventData;
  58146. /**
  58147. * Enables the vortex.
  58148. */
  58149. enable(): void;
  58150. /**
  58151. * Disables the cortex.
  58152. */
  58153. disable(): void;
  58154. /**
  58155. * Disposes the sphere.
  58156. * @param force
  58157. */
  58158. dispose(force?: boolean): void;
  58159. private getImpostorHitData;
  58160. private _tick;
  58161. /*** Helpers ***/
  58162. private _prepareCylinder;
  58163. private _intersectsWithCylinder;
  58164. }
  58165. /**
  58166. * Options fot the radial explosion event
  58167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58168. */
  58169. export class PhysicsRadialExplosionEventOptions {
  58170. /**
  58171. * The radius of the sphere for the radial explosion.
  58172. */
  58173. radius: number;
  58174. /**
  58175. * The strenth of the explosion.
  58176. */
  58177. strength: number;
  58178. /**
  58179. * The strenght of the force in correspondence to the distance of the affected object
  58180. */
  58181. falloff: PhysicsRadialImpulseFalloff;
  58182. /**
  58183. * Sphere options for the radial explosion.
  58184. */
  58185. sphere: {
  58186. segments: number;
  58187. diameter: number;
  58188. };
  58189. /**
  58190. * Sphere options for the radial explosion.
  58191. */
  58192. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58193. }
  58194. /**
  58195. * Options fot the updraft event
  58196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58197. */
  58198. export class PhysicsUpdraftEventOptions {
  58199. /**
  58200. * The radius of the cylinder for the vortex
  58201. */
  58202. radius: number;
  58203. /**
  58204. * The strenth of the updraft.
  58205. */
  58206. strength: number;
  58207. /**
  58208. * The height of the cylinder for the updraft.
  58209. */
  58210. height: number;
  58211. /**
  58212. * The mode for the the updraft.
  58213. */
  58214. updraftMode: PhysicsUpdraftMode;
  58215. }
  58216. /**
  58217. * Options fot the vortex event
  58218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58219. */
  58220. export class PhysicsVortexEventOptions {
  58221. /**
  58222. * The radius of the cylinder for the vortex
  58223. */
  58224. radius: number;
  58225. /**
  58226. * The strenth of the vortex.
  58227. */
  58228. strength: number;
  58229. /**
  58230. * The height of the cylinder for the vortex.
  58231. */
  58232. height: number;
  58233. /**
  58234. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58235. */
  58236. centripetalForceThreshold: number;
  58237. /**
  58238. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58239. */
  58240. centripetalForceMultiplier: number;
  58241. /**
  58242. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58243. */
  58244. centrifugalForceMultiplier: number;
  58245. /**
  58246. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58247. */
  58248. updraftForceMultiplier: number;
  58249. }
  58250. /**
  58251. * The strenght of the force in correspondence to the distance of the affected object
  58252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58253. */
  58254. export enum PhysicsRadialImpulseFalloff {
  58255. /** Defines that impulse is constant in strength across it's whole radius */
  58256. Constant = 0,
  58257. /** Defines that impulse gets weaker if it's further from the origin */
  58258. Linear = 1
  58259. }
  58260. /**
  58261. * The strength of the force in correspondence to the distance of the affected object
  58262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58263. */
  58264. export enum PhysicsUpdraftMode {
  58265. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58266. Center = 0,
  58267. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58268. Perpendicular = 1
  58269. }
  58270. /**
  58271. * Interface for a physics hit data
  58272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58273. */
  58274. export interface PhysicsHitData {
  58275. /**
  58276. * The force applied at the contact point
  58277. */
  58278. force: Vector3;
  58279. /**
  58280. * The contact point
  58281. */
  58282. contactPoint: Vector3;
  58283. /**
  58284. * The distance from the origin to the contact point
  58285. */
  58286. distanceFromOrigin: number;
  58287. }
  58288. /**
  58289. * Interface for radial explosion event data
  58290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58291. */
  58292. export interface PhysicsRadialExplosionEventData {
  58293. /**
  58294. * A sphere used for the radial explosion event
  58295. */
  58296. sphere: Mesh;
  58297. }
  58298. /**
  58299. * Interface for gravitational field event data
  58300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58301. */
  58302. export interface PhysicsGravitationalFieldEventData {
  58303. /**
  58304. * A sphere mesh used for the gravitational field event
  58305. */
  58306. sphere: Mesh;
  58307. }
  58308. /**
  58309. * Interface for updraft event data
  58310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58311. */
  58312. export interface PhysicsUpdraftEventData {
  58313. /**
  58314. * A cylinder used for the updraft event
  58315. */
  58316. cylinder: Mesh;
  58317. }
  58318. /**
  58319. * Interface for vortex event data
  58320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58321. */
  58322. export interface PhysicsVortexEventData {
  58323. /**
  58324. * A cylinder used for the vortex event
  58325. */
  58326. cylinder: Mesh;
  58327. }
  58328. /**
  58329. * Interface for an affected physics impostor
  58330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58331. */
  58332. export interface PhysicsAffectedImpostorWithData {
  58333. /**
  58334. * The impostor affected by the effect
  58335. */
  58336. impostor: PhysicsImpostor;
  58337. /**
  58338. * The data about the hit/horce from the explosion
  58339. */
  58340. hitData: PhysicsHitData;
  58341. }
  58342. }
  58343. declare module BABYLON {
  58344. /** @hidden */
  58345. export var blackAndWhitePixelShader: {
  58346. name: string;
  58347. shader: string;
  58348. };
  58349. }
  58350. declare module BABYLON {
  58351. /**
  58352. * Post process used to render in black and white
  58353. */
  58354. export class BlackAndWhitePostProcess extends PostProcess {
  58355. /**
  58356. * Linear about to convert he result to black and white (default: 1)
  58357. */
  58358. degree: number;
  58359. /**
  58360. * Creates a black and white post process
  58361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58362. * @param name The name of the effect.
  58363. * @param options The required width/height ratio to downsize to before computing the render pass.
  58364. * @param camera The camera to apply the render pass to.
  58365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58366. * @param engine The engine which the post process will be applied. (default: current engine)
  58367. * @param reusable If the post process can be reused on the same frame. (default: false)
  58368. */
  58369. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58370. }
  58371. }
  58372. declare module BABYLON {
  58373. /**
  58374. * This represents a set of one or more post processes in Babylon.
  58375. * A post process can be used to apply a shader to a texture after it is rendered.
  58376. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58377. */
  58378. export class PostProcessRenderEffect {
  58379. private _postProcesses;
  58380. private _getPostProcesses;
  58381. private _singleInstance;
  58382. private _cameras;
  58383. private _indicesForCamera;
  58384. /**
  58385. * Name of the effect
  58386. * @hidden
  58387. */
  58388. _name: string;
  58389. /**
  58390. * Instantiates a post process render effect.
  58391. * A post process can be used to apply a shader to a texture after it is rendered.
  58392. * @param engine The engine the effect is tied to
  58393. * @param name The name of the effect
  58394. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58395. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58396. */
  58397. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58398. /**
  58399. * Checks if all the post processes in the effect are supported.
  58400. */
  58401. readonly isSupported: boolean;
  58402. /**
  58403. * Updates the current state of the effect
  58404. * @hidden
  58405. */
  58406. _update(): void;
  58407. /**
  58408. * Attaches the effect on cameras
  58409. * @param cameras The camera to attach to.
  58410. * @hidden
  58411. */
  58412. _attachCameras(cameras: Camera): void;
  58413. /**
  58414. * Attaches the effect on cameras
  58415. * @param cameras The camera to attach to.
  58416. * @hidden
  58417. */
  58418. _attachCameras(cameras: Camera[]): void;
  58419. /**
  58420. * Detaches the effect on cameras
  58421. * @param cameras The camera to detatch from.
  58422. * @hidden
  58423. */
  58424. _detachCameras(cameras: Camera): void;
  58425. /**
  58426. * Detatches the effect on cameras
  58427. * @param cameras The camera to detatch from.
  58428. * @hidden
  58429. */
  58430. _detachCameras(cameras: Camera[]): void;
  58431. /**
  58432. * Enables the effect on given cameras
  58433. * @param cameras The camera to enable.
  58434. * @hidden
  58435. */
  58436. _enable(cameras: Camera): void;
  58437. /**
  58438. * Enables the effect on given cameras
  58439. * @param cameras The camera to enable.
  58440. * @hidden
  58441. */
  58442. _enable(cameras: Nullable<Camera[]>): void;
  58443. /**
  58444. * Disables the effect on the given cameras
  58445. * @param cameras The camera to disable.
  58446. * @hidden
  58447. */
  58448. _disable(cameras: Camera): void;
  58449. /**
  58450. * Disables the effect on the given cameras
  58451. * @param cameras The camera to disable.
  58452. * @hidden
  58453. */
  58454. _disable(cameras: Nullable<Camera[]>): void;
  58455. /**
  58456. * Gets a list of the post processes contained in the effect.
  58457. * @param camera The camera to get the post processes on.
  58458. * @returns The list of the post processes in the effect.
  58459. */
  58460. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58461. }
  58462. }
  58463. declare module BABYLON {
  58464. /** @hidden */
  58465. export var extractHighlightsPixelShader: {
  58466. name: string;
  58467. shader: string;
  58468. };
  58469. }
  58470. declare module BABYLON {
  58471. /**
  58472. * 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.
  58473. */
  58474. export class ExtractHighlightsPostProcess extends PostProcess {
  58475. /**
  58476. * The luminance threshold, pixels below this value will be set to black.
  58477. */
  58478. threshold: number;
  58479. /** @hidden */
  58480. _exposure: number;
  58481. /**
  58482. * Post process which has the input texture to be used when performing highlight extraction
  58483. * @hidden
  58484. */
  58485. _inputPostProcess: Nullable<PostProcess>;
  58486. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58487. }
  58488. }
  58489. declare module BABYLON {
  58490. /** @hidden */
  58491. export var bloomMergePixelShader: {
  58492. name: string;
  58493. shader: string;
  58494. };
  58495. }
  58496. declare module BABYLON {
  58497. /**
  58498. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58499. */
  58500. export class BloomMergePostProcess extends PostProcess {
  58501. /** Weight of the bloom to be added to the original input. */
  58502. weight: number;
  58503. /**
  58504. * Creates a new instance of @see BloomMergePostProcess
  58505. * @param name The name of the effect.
  58506. * @param originalFromInput Post process which's input will be used for the merge.
  58507. * @param blurred Blurred highlights post process which's output will be used.
  58508. * @param weight Weight of the bloom to be added to the original input.
  58509. * @param options The required width/height ratio to downsize to before computing the render pass.
  58510. * @param camera The camera to apply the render pass to.
  58511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58512. * @param engine The engine which the post process will be applied. (default: current engine)
  58513. * @param reusable If the post process can be reused on the same frame. (default: false)
  58514. * @param textureType Type of textures used when performing the post process. (default: 0)
  58515. * @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)
  58516. */
  58517. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58518. /** Weight of the bloom to be added to the original input. */
  58519. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58520. }
  58521. }
  58522. declare module BABYLON {
  58523. /**
  58524. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58525. */
  58526. export class BloomEffect extends PostProcessRenderEffect {
  58527. private bloomScale;
  58528. /**
  58529. * @hidden Internal
  58530. */
  58531. _effects: Array<PostProcess>;
  58532. /**
  58533. * @hidden Internal
  58534. */
  58535. _downscale: ExtractHighlightsPostProcess;
  58536. private _blurX;
  58537. private _blurY;
  58538. private _merge;
  58539. /**
  58540. * The luminance threshold to find bright areas of the image to bloom.
  58541. */
  58542. threshold: number;
  58543. /**
  58544. * The strength of the bloom.
  58545. */
  58546. weight: number;
  58547. /**
  58548. * Specifies the size of the bloom blur kernel, relative to the final output size
  58549. */
  58550. kernel: number;
  58551. /**
  58552. * Creates a new instance of @see BloomEffect
  58553. * @param scene The scene the effect belongs to.
  58554. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58555. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58556. * @param bloomWeight The the strength of bloom.
  58557. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58558. * @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)
  58559. */
  58560. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58561. /**
  58562. * Disposes each of the internal effects for a given camera.
  58563. * @param camera The camera to dispose the effect on.
  58564. */
  58565. disposeEffects(camera: Camera): void;
  58566. /**
  58567. * @hidden Internal
  58568. */
  58569. _updateEffects(): void;
  58570. /**
  58571. * Internal
  58572. * @returns if all the contained post processes are ready.
  58573. * @hidden
  58574. */
  58575. _isReady(): boolean;
  58576. }
  58577. }
  58578. declare module BABYLON {
  58579. /** @hidden */
  58580. export var chromaticAberrationPixelShader: {
  58581. name: string;
  58582. shader: string;
  58583. };
  58584. }
  58585. declare module BABYLON {
  58586. /**
  58587. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58588. */
  58589. export class ChromaticAberrationPostProcess extends PostProcess {
  58590. /**
  58591. * The amount of seperation of rgb channels (default: 30)
  58592. */
  58593. aberrationAmount: number;
  58594. /**
  58595. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58596. */
  58597. radialIntensity: number;
  58598. /**
  58599. * 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))
  58600. */
  58601. direction: Vector2;
  58602. /**
  58603. * 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))
  58604. */
  58605. centerPosition: Vector2;
  58606. /**
  58607. * Creates a new instance ChromaticAberrationPostProcess
  58608. * @param name The name of the effect.
  58609. * @param screenWidth The width of the screen to apply the effect on.
  58610. * @param screenHeight The height of the screen to apply the effect on.
  58611. * @param options The required width/height ratio to downsize to before computing the render pass.
  58612. * @param camera The camera to apply the render pass to.
  58613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58614. * @param engine The engine which the post process will be applied. (default: current engine)
  58615. * @param reusable If the post process can be reused on the same frame. (default: false)
  58616. * @param textureType Type of textures used when performing the post process. (default: 0)
  58617. * @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)
  58618. */
  58619. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58620. }
  58621. }
  58622. declare module BABYLON {
  58623. /** @hidden */
  58624. export var circleOfConfusionPixelShader: {
  58625. name: string;
  58626. shader: string;
  58627. };
  58628. }
  58629. declare module BABYLON {
  58630. /**
  58631. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58632. */
  58633. export class CircleOfConfusionPostProcess extends PostProcess {
  58634. /**
  58635. * 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.
  58636. */
  58637. lensSize: number;
  58638. /**
  58639. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58640. */
  58641. fStop: number;
  58642. /**
  58643. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58644. */
  58645. focusDistance: number;
  58646. /**
  58647. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58648. */
  58649. focalLength: number;
  58650. private _depthTexture;
  58651. /**
  58652. * Creates a new instance CircleOfConfusionPostProcess
  58653. * @param name The name of the effect.
  58654. * @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.
  58655. * @param options The required width/height ratio to downsize to before computing the render pass.
  58656. * @param camera The camera to apply the render pass to.
  58657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58658. * @param engine The engine which the post process will be applied. (default: current engine)
  58659. * @param reusable If the post process can be reused on the same frame. (default: false)
  58660. * @param textureType Type of textures used when performing the post process. (default: 0)
  58661. * @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)
  58662. */
  58663. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58664. /**
  58665. * 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.
  58666. */
  58667. depthTexture: RenderTargetTexture;
  58668. }
  58669. }
  58670. declare module BABYLON {
  58671. /** @hidden */
  58672. export var colorCorrectionPixelShader: {
  58673. name: string;
  58674. shader: string;
  58675. };
  58676. }
  58677. declare module BABYLON {
  58678. /**
  58679. *
  58680. * This post-process allows the modification of rendered colors by using
  58681. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58682. *
  58683. * The object needs to be provided an url to a texture containing the color
  58684. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58685. * Use an image editing software to tweak the LUT to match your needs.
  58686. *
  58687. * For an example of a color LUT, see here:
  58688. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58689. * For explanations on color grading, see here:
  58690. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58691. *
  58692. */
  58693. export class ColorCorrectionPostProcess extends PostProcess {
  58694. private _colorTableTexture;
  58695. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58696. }
  58697. }
  58698. declare module BABYLON {
  58699. /** @hidden */
  58700. export var convolutionPixelShader: {
  58701. name: string;
  58702. shader: string;
  58703. };
  58704. }
  58705. declare module BABYLON {
  58706. /**
  58707. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58708. * input texture to perform effects such as edge detection or sharpening
  58709. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58710. */
  58711. export class ConvolutionPostProcess extends PostProcess {
  58712. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58713. kernel: number[];
  58714. /**
  58715. * Creates a new instance ConvolutionPostProcess
  58716. * @param name The name of the effect.
  58717. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58718. * @param options The required width/height ratio to downsize to before computing the render pass.
  58719. * @param camera The camera to apply the render pass to.
  58720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58721. * @param engine The engine which the post process will be applied. (default: current engine)
  58722. * @param reusable If the post process can be reused on the same frame. (default: false)
  58723. * @param textureType Type of textures used when performing the post process. (default: 0)
  58724. */
  58725. constructor(name: string,
  58726. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58727. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58728. /**
  58729. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58730. */
  58731. static EdgeDetect0Kernel: number[];
  58732. /**
  58733. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58734. */
  58735. static EdgeDetect1Kernel: number[];
  58736. /**
  58737. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58738. */
  58739. static EdgeDetect2Kernel: number[];
  58740. /**
  58741. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58742. */
  58743. static SharpenKernel: number[];
  58744. /**
  58745. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58746. */
  58747. static EmbossKernel: number[];
  58748. /**
  58749. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58750. */
  58751. static GaussianKernel: number[];
  58752. }
  58753. }
  58754. declare module BABYLON {
  58755. /**
  58756. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58757. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58758. * based on samples that have a large difference in distance than the center pixel.
  58759. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58760. */
  58761. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58762. direction: Vector2;
  58763. /**
  58764. * Creates a new instance CircleOfConfusionPostProcess
  58765. * @param name The name of the effect.
  58766. * @param scene The scene the effect belongs to.
  58767. * @param direction The direction the blur should be applied.
  58768. * @param kernel The size of the kernel used to blur.
  58769. * @param options The required width/height ratio to downsize to before computing the render pass.
  58770. * @param camera The camera to apply the render pass to.
  58771. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58772. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58774. * @param engine The engine which the post process will be applied. (default: current engine)
  58775. * @param reusable If the post process can be reused on the same frame. (default: false)
  58776. * @param textureType Type of textures used when performing the post process. (default: 0)
  58777. * @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)
  58778. */
  58779. 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);
  58780. }
  58781. }
  58782. declare module BABYLON {
  58783. /** @hidden */
  58784. export var depthOfFieldMergePixelShader: {
  58785. name: string;
  58786. shader: string;
  58787. };
  58788. }
  58789. declare module BABYLON {
  58790. /**
  58791. * Options to be set when merging outputs from the default pipeline.
  58792. */
  58793. export class DepthOfFieldMergePostProcessOptions {
  58794. /**
  58795. * The original image to merge on top of
  58796. */
  58797. originalFromInput: PostProcess;
  58798. /**
  58799. * Parameters to perform the merge of the depth of field effect
  58800. */
  58801. depthOfField?: {
  58802. circleOfConfusion: PostProcess;
  58803. blurSteps: Array<PostProcess>;
  58804. };
  58805. /**
  58806. * Parameters to perform the merge of bloom effect
  58807. */
  58808. bloom?: {
  58809. blurred: PostProcess;
  58810. weight: number;
  58811. };
  58812. }
  58813. /**
  58814. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58815. */
  58816. export class DepthOfFieldMergePostProcess extends PostProcess {
  58817. private blurSteps;
  58818. /**
  58819. * Creates a new instance of DepthOfFieldMergePostProcess
  58820. * @param name The name of the effect.
  58821. * @param originalFromInput Post process which's input will be used for the merge.
  58822. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58823. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58824. * @param options The required width/height ratio to downsize to before computing the render pass.
  58825. * @param camera The camera to apply the render pass to.
  58826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58827. * @param engine The engine which the post process will be applied. (default: current engine)
  58828. * @param reusable If the post process can be reused on the same frame. (default: false)
  58829. * @param textureType Type of textures used when performing the post process. (default: 0)
  58830. * @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)
  58831. */
  58832. 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);
  58833. /**
  58834. * Updates the effect with the current post process compile time values and recompiles the shader.
  58835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58838. * @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
  58839. * @param onCompiled Called when the shader has been compiled.
  58840. * @param onError Called if there is an error when compiling a shader.
  58841. */
  58842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58843. }
  58844. }
  58845. declare module BABYLON {
  58846. /**
  58847. * Specifies the level of max blur that should be applied when using the depth of field effect
  58848. */
  58849. export enum DepthOfFieldEffectBlurLevel {
  58850. /**
  58851. * Subtle blur
  58852. */
  58853. Low = 0,
  58854. /**
  58855. * Medium blur
  58856. */
  58857. Medium = 1,
  58858. /**
  58859. * Large blur
  58860. */
  58861. High = 2
  58862. }
  58863. /**
  58864. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58865. */
  58866. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58867. private _circleOfConfusion;
  58868. /**
  58869. * @hidden Internal, blurs from high to low
  58870. */
  58871. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58872. private _depthOfFieldBlurY;
  58873. private _dofMerge;
  58874. /**
  58875. * @hidden Internal post processes in depth of field effect
  58876. */
  58877. _effects: Array<PostProcess>;
  58878. /**
  58879. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58880. */
  58881. focalLength: number;
  58882. /**
  58883. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58884. */
  58885. fStop: number;
  58886. /**
  58887. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58888. */
  58889. focusDistance: number;
  58890. /**
  58891. * 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.
  58892. */
  58893. lensSize: number;
  58894. /**
  58895. * Creates a new instance DepthOfFieldEffect
  58896. * @param scene The scene the effect belongs to.
  58897. * @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.
  58898. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58899. * @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)
  58900. */
  58901. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58902. /**
  58903. * Get the current class name of the current effet
  58904. * @returns "DepthOfFieldEffect"
  58905. */
  58906. getClassName(): string;
  58907. /**
  58908. * 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.
  58909. */
  58910. depthTexture: RenderTargetTexture;
  58911. /**
  58912. * Disposes each of the internal effects for a given camera.
  58913. * @param camera The camera to dispose the effect on.
  58914. */
  58915. disposeEffects(camera: Camera): void;
  58916. /**
  58917. * @hidden Internal
  58918. */
  58919. _updateEffects(): void;
  58920. /**
  58921. * Internal
  58922. * @returns if all the contained post processes are ready.
  58923. * @hidden
  58924. */
  58925. _isReady(): boolean;
  58926. }
  58927. }
  58928. declare module BABYLON {
  58929. /** @hidden */
  58930. export var displayPassPixelShader: {
  58931. name: string;
  58932. shader: string;
  58933. };
  58934. }
  58935. declare module BABYLON {
  58936. /**
  58937. * DisplayPassPostProcess which produces an output the same as it's input
  58938. */
  58939. export class DisplayPassPostProcess extends PostProcess {
  58940. /**
  58941. * Creates the DisplayPassPostProcess
  58942. * @param name The name of the effect.
  58943. * @param options The required width/height ratio to downsize to before computing the render pass.
  58944. * @param camera The camera to apply the render pass to.
  58945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58946. * @param engine The engine which the post process will be applied. (default: current engine)
  58947. * @param reusable If the post process can be reused on the same frame. (default: false)
  58948. */
  58949. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58950. }
  58951. }
  58952. declare module BABYLON {
  58953. /** @hidden */
  58954. export var filterPixelShader: {
  58955. name: string;
  58956. shader: string;
  58957. };
  58958. }
  58959. declare module BABYLON {
  58960. /**
  58961. * Applies a kernel filter to the image
  58962. */
  58963. export class FilterPostProcess extends PostProcess {
  58964. /** The matrix to be applied to the image */
  58965. kernelMatrix: Matrix;
  58966. /**
  58967. *
  58968. * @param name The name of the effect.
  58969. * @param kernelMatrix The matrix to be applied to the image
  58970. * @param options The required width/height ratio to downsize to before computing the render pass.
  58971. * @param camera The camera to apply the render pass to.
  58972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58973. * @param engine The engine which the post process will be applied. (default: current engine)
  58974. * @param reusable If the post process can be reused on the same frame. (default: false)
  58975. */
  58976. constructor(name: string,
  58977. /** The matrix to be applied to the image */
  58978. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58979. }
  58980. }
  58981. declare module BABYLON {
  58982. /** @hidden */
  58983. export var fxaaPixelShader: {
  58984. name: string;
  58985. shader: string;
  58986. };
  58987. }
  58988. declare module BABYLON {
  58989. /** @hidden */
  58990. export var fxaaVertexShader: {
  58991. name: string;
  58992. shader: string;
  58993. };
  58994. }
  58995. declare module BABYLON {
  58996. /**
  58997. * Fxaa post process
  58998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58999. */
  59000. export class FxaaPostProcess extends PostProcess {
  59001. /** @hidden */
  59002. texelWidth: number;
  59003. /** @hidden */
  59004. texelHeight: number;
  59005. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59006. private _getDefines;
  59007. }
  59008. }
  59009. declare module BABYLON {
  59010. /** @hidden */
  59011. export var grainPixelShader: {
  59012. name: string;
  59013. shader: string;
  59014. };
  59015. }
  59016. declare module BABYLON {
  59017. /**
  59018. * The GrainPostProcess adds noise to the image at mid luminance levels
  59019. */
  59020. export class GrainPostProcess extends PostProcess {
  59021. /**
  59022. * The intensity of the grain added (default: 30)
  59023. */
  59024. intensity: number;
  59025. /**
  59026. * If the grain should be randomized on every frame
  59027. */
  59028. animated: boolean;
  59029. /**
  59030. * Creates a new instance of @see GrainPostProcess
  59031. * @param name The name of the effect.
  59032. * @param options The required width/height ratio to downsize to before computing the render pass.
  59033. * @param camera The camera to apply the render pass to.
  59034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59035. * @param engine The engine which the post process will be applied. (default: current engine)
  59036. * @param reusable If the post process can be reused on the same frame. (default: false)
  59037. * @param textureType Type of textures used when performing the post process. (default: 0)
  59038. * @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)
  59039. */
  59040. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59041. }
  59042. }
  59043. declare module BABYLON {
  59044. /** @hidden */
  59045. export var highlightsPixelShader: {
  59046. name: string;
  59047. shader: string;
  59048. };
  59049. }
  59050. declare module BABYLON {
  59051. /**
  59052. * Extracts highlights from the image
  59053. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59054. */
  59055. export class HighlightsPostProcess extends PostProcess {
  59056. /**
  59057. * Extracts highlights from the image
  59058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59059. * @param name The name of the effect.
  59060. * @param options The required width/height ratio to downsize to before computing the render pass.
  59061. * @param camera The camera to apply the render pass to.
  59062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59063. * @param engine The engine which the post process will be applied. (default: current engine)
  59064. * @param reusable If the post process can be reused on the same frame. (default: false)
  59065. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59066. */
  59067. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59068. }
  59069. }
  59070. declare module BABYLON {
  59071. /** @hidden */
  59072. export var mrtFragmentDeclaration: {
  59073. name: string;
  59074. shader: string;
  59075. };
  59076. }
  59077. declare module BABYLON {
  59078. /** @hidden */
  59079. export var geometryPixelShader: {
  59080. name: string;
  59081. shader: string;
  59082. };
  59083. }
  59084. declare module BABYLON {
  59085. /** @hidden */
  59086. export var geometryVertexShader: {
  59087. name: string;
  59088. shader: string;
  59089. };
  59090. }
  59091. declare module BABYLON {
  59092. /** @hidden */
  59093. interface ISavedTransformationMatrix {
  59094. world: Matrix;
  59095. viewProjection: Matrix;
  59096. }
  59097. /**
  59098. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59099. */
  59100. export class GeometryBufferRenderer {
  59101. /**
  59102. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59103. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59104. */
  59105. static readonly POSITION_TEXTURE_TYPE: number;
  59106. /**
  59107. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59108. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59109. */
  59110. static readonly VELOCITY_TEXTURE_TYPE: number;
  59111. /**
  59112. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59113. * in order to compute objects velocities when enableVelocity is set to "true"
  59114. * @hidden
  59115. */
  59116. _previousTransformationMatrices: {
  59117. [index: number]: ISavedTransformationMatrix;
  59118. };
  59119. /**
  59120. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59121. * in order to compute objects velocities when enableVelocity is set to "true"
  59122. * @hidden
  59123. */
  59124. _previousBonesTransformationMatrices: {
  59125. [index: number]: Float32Array;
  59126. };
  59127. /**
  59128. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59129. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59130. */
  59131. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59132. private _scene;
  59133. private _multiRenderTarget;
  59134. private _ratio;
  59135. private _enablePosition;
  59136. private _enableVelocity;
  59137. private _positionIndex;
  59138. private _velocityIndex;
  59139. protected _effect: Effect;
  59140. protected _cachedDefines: string;
  59141. /**
  59142. * Set the render list (meshes to be rendered) used in the G buffer.
  59143. */
  59144. renderList: Mesh[];
  59145. /**
  59146. * Gets wether or not G buffer are supported by the running hardware.
  59147. * This requires draw buffer supports
  59148. */
  59149. readonly isSupported: boolean;
  59150. /**
  59151. * Returns the index of the given texture type in the G-Buffer textures array
  59152. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59153. * @returns the index of the given texture type in the G-Buffer textures array
  59154. */
  59155. getTextureIndex(textureType: number): number;
  59156. /**
  59157. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59158. */
  59159. /**
  59160. * Sets whether or not objects positions are enabled for the G buffer.
  59161. */
  59162. enablePosition: boolean;
  59163. /**
  59164. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59165. */
  59166. /**
  59167. * Sets wether or not objects velocities are enabled for the G buffer.
  59168. */
  59169. enableVelocity: boolean;
  59170. /**
  59171. * Gets the scene associated with the buffer.
  59172. */
  59173. readonly scene: Scene;
  59174. /**
  59175. * Gets the ratio used by the buffer during its creation.
  59176. * How big is the buffer related to the main canvas.
  59177. */
  59178. readonly ratio: number;
  59179. /** @hidden */
  59180. static _SceneComponentInitialization: (scene: Scene) => void;
  59181. /**
  59182. * Creates a new G Buffer for the scene
  59183. * @param scene The scene the buffer belongs to
  59184. * @param ratio How big is the buffer related to the main canvas.
  59185. */
  59186. constructor(scene: Scene, ratio?: number);
  59187. /**
  59188. * Checks wether everything is ready to render a submesh to the G buffer.
  59189. * @param subMesh the submesh to check readiness for
  59190. * @param useInstances is the mesh drawn using instance or not
  59191. * @returns true if ready otherwise false
  59192. */
  59193. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59194. /**
  59195. * Gets the current underlying G Buffer.
  59196. * @returns the buffer
  59197. */
  59198. getGBuffer(): MultiRenderTarget;
  59199. /**
  59200. * Gets the number of samples used to render the buffer (anti aliasing).
  59201. */
  59202. /**
  59203. * Sets the number of samples used to render the buffer (anti aliasing).
  59204. */
  59205. samples: number;
  59206. /**
  59207. * Disposes the renderer and frees up associated resources.
  59208. */
  59209. dispose(): void;
  59210. protected _createRenderTargets(): void;
  59211. private _copyBonesTransformationMatrices;
  59212. }
  59213. }
  59214. declare module BABYLON {
  59215. interface Scene {
  59216. /** @hidden (Backing field) */
  59217. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59218. /**
  59219. * Gets or Sets the current geometry buffer associated to the scene.
  59220. */
  59221. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59222. /**
  59223. * Enables a GeometryBufferRender and associates it with the scene
  59224. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59225. * @returns the GeometryBufferRenderer
  59226. */
  59227. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59228. /**
  59229. * Disables the GeometryBufferRender associated with the scene
  59230. */
  59231. disableGeometryBufferRenderer(): void;
  59232. }
  59233. /**
  59234. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59235. * in several rendering techniques.
  59236. */
  59237. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59238. /**
  59239. * The component name helpful to identify the component in the list of scene components.
  59240. */
  59241. readonly name: string;
  59242. /**
  59243. * The scene the component belongs to.
  59244. */
  59245. scene: Scene;
  59246. /**
  59247. * Creates a new instance of the component for the given scene
  59248. * @param scene Defines the scene to register the component in
  59249. */
  59250. constructor(scene: Scene);
  59251. /**
  59252. * Registers the component in a given scene
  59253. */
  59254. register(): void;
  59255. /**
  59256. * Rebuilds the elements related to this component in case of
  59257. * context lost for instance.
  59258. */
  59259. rebuild(): void;
  59260. /**
  59261. * Disposes the component and the associated ressources
  59262. */
  59263. dispose(): void;
  59264. private _gatherRenderTargets;
  59265. }
  59266. }
  59267. declare module BABYLON {
  59268. /** @hidden */
  59269. export var motionBlurPixelShader: {
  59270. name: string;
  59271. shader: string;
  59272. };
  59273. }
  59274. declare module BABYLON {
  59275. /**
  59276. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59277. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59278. * As an example, all you have to do is to create the post-process:
  59279. * var mb = new BABYLON.MotionBlurPostProcess(
  59280. * 'mb', // The name of the effect.
  59281. * scene, // The scene containing the objects to blur according to their velocity.
  59282. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59283. * camera // The camera to apply the render pass to.
  59284. * );
  59285. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59286. */
  59287. export class MotionBlurPostProcess extends PostProcess {
  59288. /**
  59289. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59290. */
  59291. motionStrength: number;
  59292. /**
  59293. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59294. */
  59295. /**
  59296. * Sets the number of iterations to be used for motion blur quality
  59297. */
  59298. motionBlurSamples: number;
  59299. private _motionBlurSamples;
  59300. private _geometryBufferRenderer;
  59301. /**
  59302. * Creates a new instance MotionBlurPostProcess
  59303. * @param name The name of the effect.
  59304. * @param scene The scene containing the objects to blur according to their velocity.
  59305. * @param options The required width/height ratio to downsize to before computing the render pass.
  59306. * @param camera The camera to apply the render pass to.
  59307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59308. * @param engine The engine which the post process will be applied. (default: current engine)
  59309. * @param reusable If the post process can be reused on the same frame. (default: false)
  59310. * @param textureType Type of textures used when performing the post process. (default: 0)
  59311. * @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)
  59312. */
  59313. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59314. /**
  59315. * Excludes the given skinned mesh from computing bones velocities.
  59316. * 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.
  59317. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59318. */
  59319. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59320. /**
  59321. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59322. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59323. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59324. */
  59325. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59326. /**
  59327. * Disposes the post process.
  59328. * @param camera The camera to dispose the post process on.
  59329. */
  59330. dispose(camera?: Camera): void;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /** @hidden */
  59335. export var refractionPixelShader: {
  59336. name: string;
  59337. shader: string;
  59338. };
  59339. }
  59340. declare module BABYLON {
  59341. /**
  59342. * Post process which applies a refractin texture
  59343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59344. */
  59345. export class RefractionPostProcess extends PostProcess {
  59346. /** the base color of the refraction (used to taint the rendering) */
  59347. color: Color3;
  59348. /** simulated refraction depth */
  59349. depth: number;
  59350. /** the coefficient of the base color (0 to remove base color tainting) */
  59351. colorLevel: number;
  59352. private _refTexture;
  59353. private _ownRefractionTexture;
  59354. /**
  59355. * Gets or sets the refraction texture
  59356. * Please note that you are responsible for disposing the texture if you set it manually
  59357. */
  59358. refractionTexture: Texture;
  59359. /**
  59360. * Initializes the RefractionPostProcess
  59361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59362. * @param name The name of the effect.
  59363. * @param refractionTextureUrl Url of the refraction texture to use
  59364. * @param color the base color of the refraction (used to taint the rendering)
  59365. * @param depth simulated refraction depth
  59366. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59367. * @param camera The camera to apply the render pass to.
  59368. * @param options The required width/height ratio to downsize to before computing the render pass.
  59369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59370. * @param engine The engine which the post process will be applied. (default: current engine)
  59371. * @param reusable If the post process can be reused on the same frame. (default: false)
  59372. */
  59373. constructor(name: string, refractionTextureUrl: string,
  59374. /** the base color of the refraction (used to taint the rendering) */
  59375. color: Color3,
  59376. /** simulated refraction depth */
  59377. depth: number,
  59378. /** the coefficient of the base color (0 to remove base color tainting) */
  59379. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59380. /**
  59381. * Disposes of the post process
  59382. * @param camera Camera to dispose post process on
  59383. */
  59384. dispose(camera: Camera): void;
  59385. }
  59386. }
  59387. declare module BABYLON {
  59388. /** @hidden */
  59389. export var sharpenPixelShader: {
  59390. name: string;
  59391. shader: string;
  59392. };
  59393. }
  59394. declare module BABYLON {
  59395. /**
  59396. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59397. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59398. */
  59399. export class SharpenPostProcess extends PostProcess {
  59400. /**
  59401. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59402. */
  59403. colorAmount: number;
  59404. /**
  59405. * How much sharpness should be applied (default: 0.3)
  59406. */
  59407. edgeAmount: number;
  59408. /**
  59409. * Creates a new instance ConvolutionPostProcess
  59410. * @param name The name of the effect.
  59411. * @param options The required width/height ratio to downsize to before computing the render pass.
  59412. * @param camera The camera to apply the render pass to.
  59413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59414. * @param engine The engine which the post process will be applied. (default: current engine)
  59415. * @param reusable If the post process can be reused on the same frame. (default: false)
  59416. * @param textureType Type of textures used when performing the post process. (default: 0)
  59417. * @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)
  59418. */
  59419. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59420. }
  59421. }
  59422. declare module BABYLON {
  59423. /**
  59424. * PostProcessRenderPipeline
  59425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59426. */
  59427. export class PostProcessRenderPipeline {
  59428. private engine;
  59429. private _renderEffects;
  59430. private _renderEffectsForIsolatedPass;
  59431. /**
  59432. * List of inspectable custom properties (used by the Inspector)
  59433. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59434. */
  59435. inspectableCustomProperties: IInspectable[];
  59436. /**
  59437. * @hidden
  59438. */
  59439. protected _cameras: Camera[];
  59440. /** @hidden */
  59441. _name: string;
  59442. /**
  59443. * Gets pipeline name
  59444. */
  59445. readonly name: string;
  59446. /**
  59447. * Initializes a PostProcessRenderPipeline
  59448. * @param engine engine to add the pipeline to
  59449. * @param name name of the pipeline
  59450. */
  59451. constructor(engine: Engine, name: string);
  59452. /**
  59453. * Gets the class name
  59454. * @returns "PostProcessRenderPipeline"
  59455. */
  59456. getClassName(): string;
  59457. /**
  59458. * If all the render effects in the pipeline are supported
  59459. */
  59460. readonly isSupported: boolean;
  59461. /**
  59462. * Adds an effect to the pipeline
  59463. * @param renderEffect the effect to add
  59464. */
  59465. addEffect(renderEffect: PostProcessRenderEffect): void;
  59466. /** @hidden */
  59467. _rebuild(): void;
  59468. /** @hidden */
  59469. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59470. /** @hidden */
  59471. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59472. /** @hidden */
  59473. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59474. /** @hidden */
  59475. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59476. /** @hidden */
  59477. _attachCameras(cameras: Camera, unique: boolean): void;
  59478. /** @hidden */
  59479. _attachCameras(cameras: Camera[], unique: boolean): void;
  59480. /** @hidden */
  59481. _detachCameras(cameras: Camera): void;
  59482. /** @hidden */
  59483. _detachCameras(cameras: Nullable<Camera[]>): void;
  59484. /** @hidden */
  59485. _update(): void;
  59486. /** @hidden */
  59487. _reset(): void;
  59488. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59489. /**
  59490. * Disposes of the pipeline
  59491. */
  59492. dispose(): void;
  59493. }
  59494. }
  59495. declare module BABYLON {
  59496. /**
  59497. * PostProcessRenderPipelineManager class
  59498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59499. */
  59500. export class PostProcessRenderPipelineManager {
  59501. private _renderPipelines;
  59502. /**
  59503. * Initializes a PostProcessRenderPipelineManager
  59504. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59505. */
  59506. constructor();
  59507. /**
  59508. * Gets the list of supported render pipelines
  59509. */
  59510. readonly supportedPipelines: PostProcessRenderPipeline[];
  59511. /**
  59512. * Adds a pipeline to the manager
  59513. * @param renderPipeline The pipeline to add
  59514. */
  59515. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59516. /**
  59517. * Attaches a camera to the pipeline
  59518. * @param renderPipelineName The name of the pipeline to attach to
  59519. * @param cameras the camera to attach
  59520. * @param unique if the camera can be attached multiple times to the pipeline
  59521. */
  59522. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59523. /**
  59524. * Detaches a camera from the pipeline
  59525. * @param renderPipelineName The name of the pipeline to detach from
  59526. * @param cameras the camera to detach
  59527. */
  59528. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59529. /**
  59530. * Enables an effect by name on a pipeline
  59531. * @param renderPipelineName the name of the pipeline to enable the effect in
  59532. * @param renderEffectName the name of the effect to enable
  59533. * @param cameras the cameras that the effect should be enabled on
  59534. */
  59535. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59536. /**
  59537. * Disables an effect by name on a pipeline
  59538. * @param renderPipelineName the name of the pipeline to disable the effect in
  59539. * @param renderEffectName the name of the effect to disable
  59540. * @param cameras the cameras that the effect should be disabled on
  59541. */
  59542. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59543. /**
  59544. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59545. */
  59546. update(): void;
  59547. /** @hidden */
  59548. _rebuild(): void;
  59549. /**
  59550. * Disposes of the manager and pipelines
  59551. */
  59552. dispose(): void;
  59553. }
  59554. }
  59555. declare module BABYLON {
  59556. interface Scene {
  59557. /** @hidden (Backing field) */
  59558. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59559. /**
  59560. * Gets the postprocess render pipeline manager
  59561. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59562. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59563. */
  59564. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59565. }
  59566. /**
  59567. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59568. */
  59569. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59570. /**
  59571. * The component name helpfull to identify the component in the list of scene components.
  59572. */
  59573. readonly name: string;
  59574. /**
  59575. * The scene the component belongs to.
  59576. */
  59577. scene: Scene;
  59578. /**
  59579. * Creates a new instance of the component for the given scene
  59580. * @param scene Defines the scene to register the component in
  59581. */
  59582. constructor(scene: Scene);
  59583. /**
  59584. * Registers the component in a given scene
  59585. */
  59586. register(): void;
  59587. /**
  59588. * Rebuilds the elements related to this component in case of
  59589. * context lost for instance.
  59590. */
  59591. rebuild(): void;
  59592. /**
  59593. * Disposes the component and the associated ressources
  59594. */
  59595. dispose(): void;
  59596. private _gatherRenderTargets;
  59597. }
  59598. }
  59599. declare module BABYLON {
  59600. /**
  59601. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59602. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59603. */
  59604. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59605. private _scene;
  59606. private _camerasToBeAttached;
  59607. /**
  59608. * ID of the sharpen post process,
  59609. */
  59610. private readonly SharpenPostProcessId;
  59611. /**
  59612. * @ignore
  59613. * ID of the image processing post process;
  59614. */
  59615. readonly ImageProcessingPostProcessId: string;
  59616. /**
  59617. * @ignore
  59618. * ID of the Fast Approximate Anti-Aliasing post process;
  59619. */
  59620. readonly FxaaPostProcessId: string;
  59621. /**
  59622. * ID of the chromatic aberration post process,
  59623. */
  59624. private readonly ChromaticAberrationPostProcessId;
  59625. /**
  59626. * ID of the grain post process
  59627. */
  59628. private readonly GrainPostProcessId;
  59629. /**
  59630. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59631. */
  59632. sharpen: SharpenPostProcess;
  59633. private _sharpenEffect;
  59634. private bloom;
  59635. /**
  59636. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59637. */
  59638. depthOfField: DepthOfFieldEffect;
  59639. /**
  59640. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59641. */
  59642. fxaa: FxaaPostProcess;
  59643. /**
  59644. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59645. */
  59646. imageProcessing: ImageProcessingPostProcess;
  59647. /**
  59648. * Chromatic aberration post process which will shift rgb colors in the image
  59649. */
  59650. chromaticAberration: ChromaticAberrationPostProcess;
  59651. private _chromaticAberrationEffect;
  59652. /**
  59653. * Grain post process which add noise to the image
  59654. */
  59655. grain: GrainPostProcess;
  59656. private _grainEffect;
  59657. /**
  59658. * Glow post process which adds a glow to emissive areas of the image
  59659. */
  59660. private _glowLayer;
  59661. /**
  59662. * Animations which can be used to tweak settings over a period of time
  59663. */
  59664. animations: Animation[];
  59665. private _imageProcessingConfigurationObserver;
  59666. private _sharpenEnabled;
  59667. private _bloomEnabled;
  59668. private _depthOfFieldEnabled;
  59669. private _depthOfFieldBlurLevel;
  59670. private _fxaaEnabled;
  59671. private _imageProcessingEnabled;
  59672. private _defaultPipelineTextureType;
  59673. private _bloomScale;
  59674. private _chromaticAberrationEnabled;
  59675. private _grainEnabled;
  59676. private _buildAllowed;
  59677. /**
  59678. * Gets active scene
  59679. */
  59680. readonly scene: Scene;
  59681. /**
  59682. * Enable or disable the sharpen process from the pipeline
  59683. */
  59684. sharpenEnabled: boolean;
  59685. private _resizeObserver;
  59686. private _hardwareScaleLevel;
  59687. private _bloomKernel;
  59688. /**
  59689. * Specifies the size of the bloom blur kernel, relative to the final output size
  59690. */
  59691. bloomKernel: number;
  59692. /**
  59693. * Specifies the weight of the bloom in the final rendering
  59694. */
  59695. private _bloomWeight;
  59696. /**
  59697. * Specifies the luma threshold for the area that will be blurred by the bloom
  59698. */
  59699. private _bloomThreshold;
  59700. private _hdr;
  59701. /**
  59702. * The strength of the bloom.
  59703. */
  59704. bloomWeight: number;
  59705. /**
  59706. * The strength of the bloom.
  59707. */
  59708. bloomThreshold: number;
  59709. /**
  59710. * The scale of the bloom, lower value will provide better performance.
  59711. */
  59712. bloomScale: number;
  59713. /**
  59714. * Enable or disable the bloom from the pipeline
  59715. */
  59716. bloomEnabled: boolean;
  59717. private _rebuildBloom;
  59718. /**
  59719. * If the depth of field is enabled.
  59720. */
  59721. depthOfFieldEnabled: boolean;
  59722. /**
  59723. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59724. */
  59725. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59726. /**
  59727. * If the anti aliasing is enabled.
  59728. */
  59729. fxaaEnabled: boolean;
  59730. private _samples;
  59731. /**
  59732. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59733. */
  59734. samples: number;
  59735. /**
  59736. * If image processing is enabled.
  59737. */
  59738. imageProcessingEnabled: boolean;
  59739. /**
  59740. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59741. */
  59742. glowLayerEnabled: boolean;
  59743. /**
  59744. * Gets the glow layer (or null if not defined)
  59745. */
  59746. readonly glowLayer: Nullable<GlowLayer>;
  59747. /**
  59748. * Enable or disable the chromaticAberration process from the pipeline
  59749. */
  59750. chromaticAberrationEnabled: boolean;
  59751. /**
  59752. * Enable or disable the grain process from the pipeline
  59753. */
  59754. grainEnabled: boolean;
  59755. /**
  59756. * @constructor
  59757. * @param name - The rendering pipeline name (default: "")
  59758. * @param hdr - If high dynamic range textures should be used (default: true)
  59759. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59760. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59761. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59762. */
  59763. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59764. /**
  59765. * Get the class name
  59766. * @returns "DefaultRenderingPipeline"
  59767. */
  59768. getClassName(): string;
  59769. /**
  59770. * Force the compilation of the entire pipeline.
  59771. */
  59772. prepare(): void;
  59773. private _hasCleared;
  59774. private _prevPostProcess;
  59775. private _prevPrevPostProcess;
  59776. private _setAutoClearAndTextureSharing;
  59777. private _depthOfFieldSceneObserver;
  59778. private _buildPipeline;
  59779. private _disposePostProcesses;
  59780. /**
  59781. * Adds a camera to the pipeline
  59782. * @param camera the camera to be added
  59783. */
  59784. addCamera(camera: Camera): void;
  59785. /**
  59786. * Removes a camera from the pipeline
  59787. * @param camera the camera to remove
  59788. */
  59789. removeCamera(camera: Camera): void;
  59790. /**
  59791. * Dispose of the pipeline and stop all post processes
  59792. */
  59793. dispose(): void;
  59794. /**
  59795. * Serialize the rendering pipeline (Used when exporting)
  59796. * @returns the serialized object
  59797. */
  59798. serialize(): any;
  59799. /**
  59800. * Parse the serialized pipeline
  59801. * @param source Source pipeline.
  59802. * @param scene The scene to load the pipeline to.
  59803. * @param rootUrl The URL of the serialized pipeline.
  59804. * @returns An instantiated pipeline from the serialized object.
  59805. */
  59806. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59807. }
  59808. }
  59809. declare module BABYLON {
  59810. /** @hidden */
  59811. export var lensHighlightsPixelShader: {
  59812. name: string;
  59813. shader: string;
  59814. };
  59815. }
  59816. declare module BABYLON {
  59817. /** @hidden */
  59818. export var depthOfFieldPixelShader: {
  59819. name: string;
  59820. shader: string;
  59821. };
  59822. }
  59823. declare module BABYLON {
  59824. /**
  59825. * BABYLON.JS Chromatic Aberration GLSL Shader
  59826. * Author: Olivier Guyot
  59827. * Separates very slightly R, G and B colors on the edges of the screen
  59828. * Inspired by Francois Tarlier & Martins Upitis
  59829. */
  59830. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59831. /**
  59832. * @ignore
  59833. * The chromatic aberration PostProcess id in the pipeline
  59834. */
  59835. LensChromaticAberrationEffect: string;
  59836. /**
  59837. * @ignore
  59838. * The highlights enhancing PostProcess id in the pipeline
  59839. */
  59840. HighlightsEnhancingEffect: string;
  59841. /**
  59842. * @ignore
  59843. * The depth-of-field PostProcess id in the pipeline
  59844. */
  59845. LensDepthOfFieldEffect: string;
  59846. private _scene;
  59847. private _depthTexture;
  59848. private _grainTexture;
  59849. private _chromaticAberrationPostProcess;
  59850. private _highlightsPostProcess;
  59851. private _depthOfFieldPostProcess;
  59852. private _edgeBlur;
  59853. private _grainAmount;
  59854. private _chromaticAberration;
  59855. private _distortion;
  59856. private _highlightsGain;
  59857. private _highlightsThreshold;
  59858. private _dofDistance;
  59859. private _dofAperture;
  59860. private _dofDarken;
  59861. private _dofPentagon;
  59862. private _blurNoise;
  59863. /**
  59864. * @constructor
  59865. *
  59866. * Effect parameters are as follow:
  59867. * {
  59868. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59869. * edge_blur: number; // from 0 to x (1 for realism)
  59870. * distortion: number; // from 0 to x (1 for realism)
  59871. * grain_amount: number; // from 0 to 1
  59872. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59873. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59874. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59875. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59876. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59877. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59878. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59879. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59880. * }
  59881. * Note: if an effect parameter is unset, effect is disabled
  59882. *
  59883. * @param name The rendering pipeline name
  59884. * @param parameters - An object containing all parameters (see above)
  59885. * @param scene The scene linked to this pipeline
  59886. * @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)
  59887. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59888. */
  59889. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59890. /**
  59891. * Get the class name
  59892. * @returns "LensRenderingPipeline"
  59893. */
  59894. getClassName(): string;
  59895. /**
  59896. * Gets associated scene
  59897. */
  59898. readonly scene: Scene;
  59899. /**
  59900. * Gets or sets the edge blur
  59901. */
  59902. edgeBlur: number;
  59903. /**
  59904. * Gets or sets the grain amount
  59905. */
  59906. grainAmount: number;
  59907. /**
  59908. * Gets or sets the chromatic aberration amount
  59909. */
  59910. chromaticAberration: number;
  59911. /**
  59912. * Gets or sets the depth of field aperture
  59913. */
  59914. dofAperture: number;
  59915. /**
  59916. * Gets or sets the edge distortion
  59917. */
  59918. edgeDistortion: number;
  59919. /**
  59920. * Gets or sets the depth of field distortion
  59921. */
  59922. dofDistortion: number;
  59923. /**
  59924. * Gets or sets the darken out of focus amount
  59925. */
  59926. darkenOutOfFocus: number;
  59927. /**
  59928. * Gets or sets a boolean indicating if blur noise is enabled
  59929. */
  59930. blurNoise: boolean;
  59931. /**
  59932. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59933. */
  59934. pentagonBokeh: boolean;
  59935. /**
  59936. * Gets or sets the highlight grain amount
  59937. */
  59938. highlightsGain: number;
  59939. /**
  59940. * Gets or sets the highlight threshold
  59941. */
  59942. highlightsThreshold: number;
  59943. /**
  59944. * Sets the amount of blur at the edges
  59945. * @param amount blur amount
  59946. */
  59947. setEdgeBlur(amount: number): void;
  59948. /**
  59949. * Sets edge blur to 0
  59950. */
  59951. disableEdgeBlur(): void;
  59952. /**
  59953. * Sets the amout of grain
  59954. * @param amount Amount of grain
  59955. */
  59956. setGrainAmount(amount: number): void;
  59957. /**
  59958. * Set grain amount to 0
  59959. */
  59960. disableGrain(): void;
  59961. /**
  59962. * Sets the chromatic aberration amount
  59963. * @param amount amount of chromatic aberration
  59964. */
  59965. setChromaticAberration(amount: number): void;
  59966. /**
  59967. * Sets chromatic aberration amount to 0
  59968. */
  59969. disableChromaticAberration(): void;
  59970. /**
  59971. * Sets the EdgeDistortion amount
  59972. * @param amount amount of EdgeDistortion
  59973. */
  59974. setEdgeDistortion(amount: number): void;
  59975. /**
  59976. * Sets edge distortion to 0
  59977. */
  59978. disableEdgeDistortion(): void;
  59979. /**
  59980. * Sets the FocusDistance amount
  59981. * @param amount amount of FocusDistance
  59982. */
  59983. setFocusDistance(amount: number): void;
  59984. /**
  59985. * Disables depth of field
  59986. */
  59987. disableDepthOfField(): void;
  59988. /**
  59989. * Sets the Aperture amount
  59990. * @param amount amount of Aperture
  59991. */
  59992. setAperture(amount: number): void;
  59993. /**
  59994. * Sets the DarkenOutOfFocus amount
  59995. * @param amount amount of DarkenOutOfFocus
  59996. */
  59997. setDarkenOutOfFocus(amount: number): void;
  59998. private _pentagonBokehIsEnabled;
  59999. /**
  60000. * Creates a pentagon bokeh effect
  60001. */
  60002. enablePentagonBokeh(): void;
  60003. /**
  60004. * Disables the pentagon bokeh effect
  60005. */
  60006. disablePentagonBokeh(): void;
  60007. /**
  60008. * Enables noise blur
  60009. */
  60010. enableNoiseBlur(): void;
  60011. /**
  60012. * Disables noise blur
  60013. */
  60014. disableNoiseBlur(): void;
  60015. /**
  60016. * Sets the HighlightsGain amount
  60017. * @param amount amount of HighlightsGain
  60018. */
  60019. setHighlightsGain(amount: number): void;
  60020. /**
  60021. * Sets the HighlightsThreshold amount
  60022. * @param amount amount of HighlightsThreshold
  60023. */
  60024. setHighlightsThreshold(amount: number): void;
  60025. /**
  60026. * Disables highlights
  60027. */
  60028. disableHighlights(): void;
  60029. /**
  60030. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60031. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60032. */
  60033. dispose(disableDepthRender?: boolean): void;
  60034. private _createChromaticAberrationPostProcess;
  60035. private _createHighlightsPostProcess;
  60036. private _createDepthOfFieldPostProcess;
  60037. private _createGrainTexture;
  60038. }
  60039. }
  60040. declare module BABYLON {
  60041. /** @hidden */
  60042. export var ssao2PixelShader: {
  60043. name: string;
  60044. shader: string;
  60045. };
  60046. }
  60047. declare module BABYLON {
  60048. /** @hidden */
  60049. export var ssaoCombinePixelShader: {
  60050. name: string;
  60051. shader: string;
  60052. };
  60053. }
  60054. declare module BABYLON {
  60055. /**
  60056. * Render pipeline to produce ssao effect
  60057. */
  60058. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60059. /**
  60060. * @ignore
  60061. * The PassPostProcess id in the pipeline that contains the original scene color
  60062. */
  60063. SSAOOriginalSceneColorEffect: string;
  60064. /**
  60065. * @ignore
  60066. * The SSAO PostProcess id in the pipeline
  60067. */
  60068. SSAORenderEffect: string;
  60069. /**
  60070. * @ignore
  60071. * The horizontal blur PostProcess id in the pipeline
  60072. */
  60073. SSAOBlurHRenderEffect: string;
  60074. /**
  60075. * @ignore
  60076. * The vertical blur PostProcess id in the pipeline
  60077. */
  60078. SSAOBlurVRenderEffect: string;
  60079. /**
  60080. * @ignore
  60081. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60082. */
  60083. SSAOCombineRenderEffect: string;
  60084. /**
  60085. * The output strength of the SSAO post-process. Default value is 1.0.
  60086. */
  60087. totalStrength: number;
  60088. /**
  60089. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60090. */
  60091. maxZ: number;
  60092. /**
  60093. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60094. */
  60095. minZAspect: number;
  60096. private _samples;
  60097. /**
  60098. * Number of samples used for the SSAO calculations. Default value is 8
  60099. */
  60100. samples: number;
  60101. private _textureSamples;
  60102. /**
  60103. * Number of samples to use for antialiasing
  60104. */
  60105. textureSamples: number;
  60106. /**
  60107. * Ratio object used for SSAO ratio and blur ratio
  60108. */
  60109. private _ratio;
  60110. /**
  60111. * Dynamically generated sphere sampler.
  60112. */
  60113. private _sampleSphere;
  60114. /**
  60115. * Blur filter offsets
  60116. */
  60117. private _samplerOffsets;
  60118. private _expensiveBlur;
  60119. /**
  60120. * If bilateral blur should be used
  60121. */
  60122. expensiveBlur: boolean;
  60123. /**
  60124. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60125. */
  60126. radius: number;
  60127. /**
  60128. * The base color of the SSAO post-process
  60129. * The final result is "base + ssao" between [0, 1]
  60130. */
  60131. base: number;
  60132. /**
  60133. * Support test.
  60134. */
  60135. static readonly IsSupported: boolean;
  60136. private _scene;
  60137. private _depthTexture;
  60138. private _normalTexture;
  60139. private _randomTexture;
  60140. private _originalColorPostProcess;
  60141. private _ssaoPostProcess;
  60142. private _blurHPostProcess;
  60143. private _blurVPostProcess;
  60144. private _ssaoCombinePostProcess;
  60145. private _firstUpdate;
  60146. /**
  60147. * Gets active scene
  60148. */
  60149. readonly scene: Scene;
  60150. /**
  60151. * @constructor
  60152. * @param name The rendering pipeline name
  60153. * @param scene The scene linked to this pipeline
  60154. * @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 }
  60155. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60156. */
  60157. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60158. /**
  60159. * Get the class name
  60160. * @returns "SSAO2RenderingPipeline"
  60161. */
  60162. getClassName(): string;
  60163. /**
  60164. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60165. */
  60166. dispose(disableGeometryBufferRenderer?: boolean): void;
  60167. private _createBlurPostProcess;
  60168. /** @hidden */
  60169. _rebuild(): void;
  60170. private _bits;
  60171. private _radicalInverse_VdC;
  60172. private _hammersley;
  60173. private _hemisphereSample_uniform;
  60174. private _generateHemisphere;
  60175. private _createSSAOPostProcess;
  60176. private _createSSAOCombinePostProcess;
  60177. private _createRandomTexture;
  60178. /**
  60179. * Serialize the rendering pipeline (Used when exporting)
  60180. * @returns the serialized object
  60181. */
  60182. serialize(): any;
  60183. /**
  60184. * Parse the serialized pipeline
  60185. * @param source Source pipeline.
  60186. * @param scene The scene to load the pipeline to.
  60187. * @param rootUrl The URL of the serialized pipeline.
  60188. * @returns An instantiated pipeline from the serialized object.
  60189. */
  60190. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60191. }
  60192. }
  60193. declare module BABYLON {
  60194. /** @hidden */
  60195. export var ssaoPixelShader: {
  60196. name: string;
  60197. shader: string;
  60198. };
  60199. }
  60200. declare module BABYLON {
  60201. /**
  60202. * Render pipeline to produce ssao effect
  60203. */
  60204. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60205. /**
  60206. * @ignore
  60207. * The PassPostProcess id in the pipeline that contains the original scene color
  60208. */
  60209. SSAOOriginalSceneColorEffect: string;
  60210. /**
  60211. * @ignore
  60212. * The SSAO PostProcess id in the pipeline
  60213. */
  60214. SSAORenderEffect: string;
  60215. /**
  60216. * @ignore
  60217. * The horizontal blur PostProcess id in the pipeline
  60218. */
  60219. SSAOBlurHRenderEffect: string;
  60220. /**
  60221. * @ignore
  60222. * The vertical blur PostProcess id in the pipeline
  60223. */
  60224. SSAOBlurVRenderEffect: string;
  60225. /**
  60226. * @ignore
  60227. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60228. */
  60229. SSAOCombineRenderEffect: string;
  60230. /**
  60231. * The output strength of the SSAO post-process. Default value is 1.0.
  60232. */
  60233. totalStrength: number;
  60234. /**
  60235. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60236. */
  60237. radius: number;
  60238. /**
  60239. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60240. * Must not be equal to fallOff and superior to fallOff.
  60241. * Default value is 0.0075
  60242. */
  60243. area: number;
  60244. /**
  60245. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60246. * Must not be equal to area and inferior to area.
  60247. * Default value is 0.000001
  60248. */
  60249. fallOff: number;
  60250. /**
  60251. * The base color of the SSAO post-process
  60252. * The final result is "base + ssao" between [0, 1]
  60253. */
  60254. base: number;
  60255. private _scene;
  60256. private _depthTexture;
  60257. private _randomTexture;
  60258. private _originalColorPostProcess;
  60259. private _ssaoPostProcess;
  60260. private _blurHPostProcess;
  60261. private _blurVPostProcess;
  60262. private _ssaoCombinePostProcess;
  60263. private _firstUpdate;
  60264. /**
  60265. * Gets active scene
  60266. */
  60267. readonly scene: Scene;
  60268. /**
  60269. * @constructor
  60270. * @param name - The rendering pipeline name
  60271. * @param scene - The scene linked to this pipeline
  60272. * @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 }
  60273. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60274. */
  60275. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60276. /**
  60277. * Get the class name
  60278. * @returns "SSAORenderingPipeline"
  60279. */
  60280. getClassName(): string;
  60281. /**
  60282. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60283. */
  60284. dispose(disableDepthRender?: boolean): void;
  60285. private _createBlurPostProcess;
  60286. /** @hidden */
  60287. _rebuild(): void;
  60288. private _createSSAOPostProcess;
  60289. private _createSSAOCombinePostProcess;
  60290. private _createRandomTexture;
  60291. }
  60292. }
  60293. declare module BABYLON {
  60294. /** @hidden */
  60295. export var standardPixelShader: {
  60296. name: string;
  60297. shader: string;
  60298. };
  60299. }
  60300. declare module BABYLON {
  60301. /**
  60302. * Standard rendering pipeline
  60303. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60304. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60305. */
  60306. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60307. /**
  60308. * Public members
  60309. */
  60310. /**
  60311. * Post-process which contains the original scene color before the pipeline applies all the effects
  60312. */
  60313. originalPostProcess: Nullable<PostProcess>;
  60314. /**
  60315. * Post-process used to down scale an image x4
  60316. */
  60317. downSampleX4PostProcess: Nullable<PostProcess>;
  60318. /**
  60319. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60320. */
  60321. brightPassPostProcess: Nullable<PostProcess>;
  60322. /**
  60323. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60324. */
  60325. blurHPostProcesses: PostProcess[];
  60326. /**
  60327. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60328. */
  60329. blurVPostProcesses: PostProcess[];
  60330. /**
  60331. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60332. */
  60333. textureAdderPostProcess: Nullable<PostProcess>;
  60334. /**
  60335. * Post-process used to create volumetric lighting effect
  60336. */
  60337. volumetricLightPostProcess: Nullable<PostProcess>;
  60338. /**
  60339. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60340. */
  60341. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60342. /**
  60343. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60344. */
  60345. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60346. /**
  60347. * Post-process used to merge the volumetric light effect and the real scene color
  60348. */
  60349. volumetricLightMergePostProces: Nullable<PostProcess>;
  60350. /**
  60351. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60352. */
  60353. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60354. /**
  60355. * Base post-process used to calculate the average luminance of the final image for HDR
  60356. */
  60357. luminancePostProcess: Nullable<PostProcess>;
  60358. /**
  60359. * Post-processes used to create down sample post-processes in order to get
  60360. * the average luminance of the final image for HDR
  60361. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60362. */
  60363. luminanceDownSamplePostProcesses: PostProcess[];
  60364. /**
  60365. * Post-process used to create a HDR effect (light adaptation)
  60366. */
  60367. hdrPostProcess: Nullable<PostProcess>;
  60368. /**
  60369. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60370. */
  60371. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60372. /**
  60373. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60374. */
  60375. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60376. /**
  60377. * Post-process used to merge the final HDR post-process and the real scene color
  60378. */
  60379. hdrFinalPostProcess: Nullable<PostProcess>;
  60380. /**
  60381. * Post-process used to create a lens flare effect
  60382. */
  60383. lensFlarePostProcess: Nullable<PostProcess>;
  60384. /**
  60385. * Post-process that merges the result of the lens flare post-process and the real scene color
  60386. */
  60387. lensFlareComposePostProcess: Nullable<PostProcess>;
  60388. /**
  60389. * Post-process used to create a motion blur effect
  60390. */
  60391. motionBlurPostProcess: Nullable<PostProcess>;
  60392. /**
  60393. * Post-process used to create a depth of field effect
  60394. */
  60395. depthOfFieldPostProcess: Nullable<PostProcess>;
  60396. /**
  60397. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60398. */
  60399. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60400. /**
  60401. * Represents the brightness threshold in order to configure the illuminated surfaces
  60402. */
  60403. brightThreshold: number;
  60404. /**
  60405. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60406. */
  60407. blurWidth: number;
  60408. /**
  60409. * Sets if the blur for highlighted surfaces must be only horizontal
  60410. */
  60411. horizontalBlur: boolean;
  60412. /**
  60413. * Gets the overall exposure used by the pipeline
  60414. */
  60415. /**
  60416. * Sets the overall exposure used by the pipeline
  60417. */
  60418. exposure: number;
  60419. /**
  60420. * Texture used typically to simulate "dirty" on camera lens
  60421. */
  60422. lensTexture: Nullable<Texture>;
  60423. /**
  60424. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60425. */
  60426. volumetricLightCoefficient: number;
  60427. /**
  60428. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60429. */
  60430. volumetricLightPower: number;
  60431. /**
  60432. * Used the set the blur intensity to smooth the volumetric lights
  60433. */
  60434. volumetricLightBlurScale: number;
  60435. /**
  60436. * Light (spot or directional) used to generate the volumetric lights rays
  60437. * The source light must have a shadow generate so the pipeline can get its
  60438. * depth map
  60439. */
  60440. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60441. /**
  60442. * For eye adaptation, represents the minimum luminance the eye can see
  60443. */
  60444. hdrMinimumLuminance: number;
  60445. /**
  60446. * For eye adaptation, represents the decrease luminance speed
  60447. */
  60448. hdrDecreaseRate: number;
  60449. /**
  60450. * For eye adaptation, represents the increase luminance speed
  60451. */
  60452. hdrIncreaseRate: number;
  60453. /**
  60454. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60455. */
  60456. /**
  60457. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60458. */
  60459. hdrAutoExposure: boolean;
  60460. /**
  60461. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60462. */
  60463. lensColorTexture: Nullable<Texture>;
  60464. /**
  60465. * The overall strengh for the lens flare effect
  60466. */
  60467. lensFlareStrength: number;
  60468. /**
  60469. * Dispersion coefficient for lens flare ghosts
  60470. */
  60471. lensFlareGhostDispersal: number;
  60472. /**
  60473. * Main lens flare halo width
  60474. */
  60475. lensFlareHaloWidth: number;
  60476. /**
  60477. * Based on the lens distortion effect, defines how much the lens flare result
  60478. * is distorted
  60479. */
  60480. lensFlareDistortionStrength: number;
  60481. /**
  60482. * Configures the blur intensity used for for lens flare (halo)
  60483. */
  60484. lensFlareBlurWidth: number;
  60485. /**
  60486. * Lens star texture must be used to simulate rays on the flares and is available
  60487. * in the documentation
  60488. */
  60489. lensStarTexture: Nullable<Texture>;
  60490. /**
  60491. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60492. * flare effect by taking account of the dirt texture
  60493. */
  60494. lensFlareDirtTexture: Nullable<Texture>;
  60495. /**
  60496. * Represents the focal length for the depth of field effect
  60497. */
  60498. depthOfFieldDistance: number;
  60499. /**
  60500. * Represents the blur intensity for the blurred part of the depth of field effect
  60501. */
  60502. depthOfFieldBlurWidth: number;
  60503. /**
  60504. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60505. */
  60506. /**
  60507. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60508. */
  60509. motionStrength: number;
  60510. /**
  60511. * Gets wether or not the motion blur post-process is object based or screen based.
  60512. */
  60513. /**
  60514. * Sets wether or not the motion blur post-process should be object based or screen based
  60515. */
  60516. objectBasedMotionBlur: boolean;
  60517. /**
  60518. * List of animations for the pipeline (IAnimatable implementation)
  60519. */
  60520. animations: Animation[];
  60521. /**
  60522. * Private members
  60523. */
  60524. private _scene;
  60525. private _currentDepthOfFieldSource;
  60526. private _basePostProcess;
  60527. private _fixedExposure;
  60528. private _currentExposure;
  60529. private _hdrAutoExposure;
  60530. private _hdrCurrentLuminance;
  60531. private _motionStrength;
  60532. private _isObjectBasedMotionBlur;
  60533. private _floatTextureType;
  60534. private _camerasToBeAttached;
  60535. private _ratio;
  60536. private _bloomEnabled;
  60537. private _depthOfFieldEnabled;
  60538. private _vlsEnabled;
  60539. private _lensFlareEnabled;
  60540. private _hdrEnabled;
  60541. private _motionBlurEnabled;
  60542. private _fxaaEnabled;
  60543. private _motionBlurSamples;
  60544. private _volumetricLightStepsCount;
  60545. private _samples;
  60546. /**
  60547. * @ignore
  60548. * Specifies if the bloom pipeline is enabled
  60549. */
  60550. BloomEnabled: boolean;
  60551. /**
  60552. * @ignore
  60553. * Specifies if the depth of field pipeline is enabed
  60554. */
  60555. DepthOfFieldEnabled: boolean;
  60556. /**
  60557. * @ignore
  60558. * Specifies if the lens flare pipeline is enabed
  60559. */
  60560. LensFlareEnabled: boolean;
  60561. /**
  60562. * @ignore
  60563. * Specifies if the HDR pipeline is enabled
  60564. */
  60565. HDREnabled: boolean;
  60566. /**
  60567. * @ignore
  60568. * Specifies if the volumetric lights scattering effect is enabled
  60569. */
  60570. VLSEnabled: boolean;
  60571. /**
  60572. * @ignore
  60573. * Specifies if the motion blur effect is enabled
  60574. */
  60575. MotionBlurEnabled: boolean;
  60576. /**
  60577. * Specifies if anti-aliasing is enabled
  60578. */
  60579. fxaaEnabled: boolean;
  60580. /**
  60581. * Specifies the number of steps used to calculate the volumetric lights
  60582. * Typically in interval [50, 200]
  60583. */
  60584. volumetricLightStepsCount: number;
  60585. /**
  60586. * Specifies the number of samples used for the motion blur effect
  60587. * Typically in interval [16, 64]
  60588. */
  60589. motionBlurSamples: number;
  60590. /**
  60591. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60592. */
  60593. samples: number;
  60594. /**
  60595. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60596. * @constructor
  60597. * @param name The rendering pipeline name
  60598. * @param scene The scene linked to this pipeline
  60599. * @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)
  60600. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60601. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60602. */
  60603. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60604. private _buildPipeline;
  60605. private _createDownSampleX4PostProcess;
  60606. private _createBrightPassPostProcess;
  60607. private _createBlurPostProcesses;
  60608. private _createTextureAdderPostProcess;
  60609. private _createVolumetricLightPostProcess;
  60610. private _createLuminancePostProcesses;
  60611. private _createHdrPostProcess;
  60612. private _createLensFlarePostProcess;
  60613. private _createDepthOfFieldPostProcess;
  60614. private _createMotionBlurPostProcess;
  60615. private _getDepthTexture;
  60616. private _disposePostProcesses;
  60617. /**
  60618. * Dispose of the pipeline and stop all post processes
  60619. */
  60620. dispose(): void;
  60621. /**
  60622. * Serialize the rendering pipeline (Used when exporting)
  60623. * @returns the serialized object
  60624. */
  60625. serialize(): any;
  60626. /**
  60627. * Parse the serialized pipeline
  60628. * @param source Source pipeline.
  60629. * @param scene The scene to load the pipeline to.
  60630. * @param rootUrl The URL of the serialized pipeline.
  60631. * @returns An instantiated pipeline from the serialized object.
  60632. */
  60633. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60634. /**
  60635. * Luminance steps
  60636. */
  60637. static LuminanceSteps: number;
  60638. }
  60639. }
  60640. declare module BABYLON {
  60641. /** @hidden */
  60642. export var tonemapPixelShader: {
  60643. name: string;
  60644. shader: string;
  60645. };
  60646. }
  60647. declare module BABYLON {
  60648. /** Defines operator used for tonemapping */
  60649. export enum TonemappingOperator {
  60650. /** Hable */
  60651. Hable = 0,
  60652. /** Reinhard */
  60653. Reinhard = 1,
  60654. /** HejiDawson */
  60655. HejiDawson = 2,
  60656. /** Photographic */
  60657. Photographic = 3
  60658. }
  60659. /**
  60660. * Defines a post process to apply tone mapping
  60661. */
  60662. export class TonemapPostProcess extends PostProcess {
  60663. private _operator;
  60664. /** Defines the required exposure adjustement */
  60665. exposureAdjustment: number;
  60666. /**
  60667. * Creates a new TonemapPostProcess
  60668. * @param name defines the name of the postprocess
  60669. * @param _operator defines the operator to use
  60670. * @param exposureAdjustment defines the required exposure adjustement
  60671. * @param camera defines the camera to use (can be null)
  60672. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60673. * @param engine defines the hosting engine (can be ignore if camera is set)
  60674. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60675. */
  60676. constructor(name: string, _operator: TonemappingOperator,
  60677. /** Defines the required exposure adjustement */
  60678. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60679. }
  60680. }
  60681. declare module BABYLON {
  60682. /** @hidden */
  60683. export var depthVertexShader: {
  60684. name: string;
  60685. shader: string;
  60686. };
  60687. }
  60688. declare module BABYLON {
  60689. /** @hidden */
  60690. export var volumetricLightScatteringPixelShader: {
  60691. name: string;
  60692. shader: string;
  60693. };
  60694. }
  60695. declare module BABYLON {
  60696. /** @hidden */
  60697. export var volumetricLightScatteringPassVertexShader: {
  60698. name: string;
  60699. shader: string;
  60700. };
  60701. }
  60702. declare module BABYLON {
  60703. /** @hidden */
  60704. export var volumetricLightScatteringPassPixelShader: {
  60705. name: string;
  60706. shader: string;
  60707. };
  60708. }
  60709. declare module BABYLON {
  60710. /**
  60711. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60712. */
  60713. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60714. private _volumetricLightScatteringPass;
  60715. private _volumetricLightScatteringRTT;
  60716. private _viewPort;
  60717. private _screenCoordinates;
  60718. private _cachedDefines;
  60719. /**
  60720. * If not undefined, the mesh position is computed from the attached node position
  60721. */
  60722. attachedNode: {
  60723. position: Vector3;
  60724. };
  60725. /**
  60726. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60727. */
  60728. customMeshPosition: Vector3;
  60729. /**
  60730. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60731. */
  60732. useCustomMeshPosition: boolean;
  60733. /**
  60734. * If the post-process should inverse the light scattering direction
  60735. */
  60736. invert: boolean;
  60737. /**
  60738. * The internal mesh used by the post-process
  60739. */
  60740. mesh: Mesh;
  60741. /**
  60742. * @hidden
  60743. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60744. */
  60745. useDiffuseColor: boolean;
  60746. /**
  60747. * Array containing the excluded meshes not rendered in the internal pass
  60748. */
  60749. excludedMeshes: AbstractMesh[];
  60750. /**
  60751. * Controls the overall intensity of the post-process
  60752. */
  60753. exposure: number;
  60754. /**
  60755. * Dissipates each sample's contribution in range [0, 1]
  60756. */
  60757. decay: number;
  60758. /**
  60759. * Controls the overall intensity of each sample
  60760. */
  60761. weight: number;
  60762. /**
  60763. * Controls the density of each sample
  60764. */
  60765. density: number;
  60766. /**
  60767. * @constructor
  60768. * @param name The post-process name
  60769. * @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)
  60770. * @param camera The camera that the post-process will be attached to
  60771. * @param mesh The mesh used to create the light scattering
  60772. * @param samples The post-process quality, default 100
  60773. * @param samplingModeThe post-process filtering mode
  60774. * @param engine The babylon engine
  60775. * @param reusable If the post-process is reusable
  60776. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60777. */
  60778. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60779. /**
  60780. * Returns the string "VolumetricLightScatteringPostProcess"
  60781. * @returns "VolumetricLightScatteringPostProcess"
  60782. */
  60783. getClassName(): string;
  60784. private _isReady;
  60785. /**
  60786. * Sets the new light position for light scattering effect
  60787. * @param position The new custom light position
  60788. */
  60789. setCustomMeshPosition(position: Vector3): void;
  60790. /**
  60791. * Returns the light position for light scattering effect
  60792. * @return Vector3 The custom light position
  60793. */
  60794. getCustomMeshPosition(): Vector3;
  60795. /**
  60796. * Disposes the internal assets and detaches the post-process from the camera
  60797. */
  60798. dispose(camera: Camera): void;
  60799. /**
  60800. * Returns the render target texture used by the post-process
  60801. * @return the render target texture used by the post-process
  60802. */
  60803. getPass(): RenderTargetTexture;
  60804. private _meshExcluded;
  60805. private _createPass;
  60806. private _updateMeshScreenCoordinates;
  60807. /**
  60808. * Creates a default mesh for the Volumeric Light Scattering post-process
  60809. * @param name The mesh name
  60810. * @param scene The scene where to create the mesh
  60811. * @return the default mesh
  60812. */
  60813. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60814. }
  60815. }
  60816. declare module BABYLON {
  60817. interface Scene {
  60818. /** @hidden (Backing field) */
  60819. _boundingBoxRenderer: BoundingBoxRenderer;
  60820. /** @hidden (Backing field) */
  60821. _forceShowBoundingBoxes: boolean;
  60822. /**
  60823. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60824. */
  60825. forceShowBoundingBoxes: boolean;
  60826. /**
  60827. * Gets the bounding box renderer associated with the scene
  60828. * @returns a BoundingBoxRenderer
  60829. */
  60830. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60831. }
  60832. interface AbstractMesh {
  60833. /** @hidden (Backing field) */
  60834. _showBoundingBox: boolean;
  60835. /**
  60836. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60837. */
  60838. showBoundingBox: boolean;
  60839. }
  60840. /**
  60841. * Component responsible of rendering the bounding box of the meshes in a scene.
  60842. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60843. */
  60844. export class BoundingBoxRenderer implements ISceneComponent {
  60845. /**
  60846. * The component name helpfull to identify the component in the list of scene components.
  60847. */
  60848. readonly name: string;
  60849. /**
  60850. * The scene the component belongs to.
  60851. */
  60852. scene: Scene;
  60853. /**
  60854. * Color of the bounding box lines placed in front of an object
  60855. */
  60856. frontColor: Color3;
  60857. /**
  60858. * Color of the bounding box lines placed behind an object
  60859. */
  60860. backColor: Color3;
  60861. /**
  60862. * Defines if the renderer should show the back lines or not
  60863. */
  60864. showBackLines: boolean;
  60865. /**
  60866. * @hidden
  60867. */
  60868. renderList: SmartArray<BoundingBox>;
  60869. private _colorShader;
  60870. private _vertexBuffers;
  60871. private _indexBuffer;
  60872. private _fillIndexBuffer;
  60873. private _fillIndexData;
  60874. /**
  60875. * Instantiates a new bounding box renderer in a scene.
  60876. * @param scene the scene the renderer renders in
  60877. */
  60878. constructor(scene: Scene);
  60879. /**
  60880. * Registers the component in a given scene
  60881. */
  60882. register(): void;
  60883. private _evaluateSubMesh;
  60884. private _activeMesh;
  60885. private _prepareRessources;
  60886. private _createIndexBuffer;
  60887. /**
  60888. * Rebuilds the elements related to this component in case of
  60889. * context lost for instance.
  60890. */
  60891. rebuild(): void;
  60892. /**
  60893. * @hidden
  60894. */
  60895. reset(): void;
  60896. /**
  60897. * Render the bounding boxes of a specific rendering group
  60898. * @param renderingGroupId defines the rendering group to render
  60899. */
  60900. render(renderingGroupId: number): void;
  60901. /**
  60902. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60903. * @param mesh Define the mesh to render the occlusion bounding box for
  60904. */
  60905. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60906. /**
  60907. * Dispose and release the resources attached to this renderer.
  60908. */
  60909. dispose(): void;
  60910. }
  60911. }
  60912. declare module BABYLON {
  60913. /** @hidden */
  60914. export var depthPixelShader: {
  60915. name: string;
  60916. shader: string;
  60917. };
  60918. }
  60919. declare module BABYLON {
  60920. /**
  60921. * This represents a depth renderer in Babylon.
  60922. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60923. */
  60924. export class DepthRenderer {
  60925. private _scene;
  60926. private _depthMap;
  60927. private _effect;
  60928. private readonly _storeNonLinearDepth;
  60929. private readonly _clearColor;
  60930. /** Get if the depth renderer is using packed depth or not */
  60931. readonly isPacked: boolean;
  60932. private _cachedDefines;
  60933. private _camera;
  60934. /**
  60935. * Specifiess that the depth renderer will only be used within
  60936. * the camera it is created for.
  60937. * This can help forcing its rendering during the camera processing.
  60938. */
  60939. useOnlyInActiveCamera: boolean;
  60940. /** @hidden */
  60941. static _SceneComponentInitialization: (scene: Scene) => void;
  60942. /**
  60943. * Instantiates a depth renderer
  60944. * @param scene The scene the renderer belongs to
  60945. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60946. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60947. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60948. */
  60949. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60950. /**
  60951. * Creates the depth rendering effect and checks if the effect is ready.
  60952. * @param subMesh The submesh to be used to render the depth map of
  60953. * @param useInstances If multiple world instances should be used
  60954. * @returns if the depth renderer is ready to render the depth map
  60955. */
  60956. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60957. /**
  60958. * Gets the texture which the depth map will be written to.
  60959. * @returns The depth map texture
  60960. */
  60961. getDepthMap(): RenderTargetTexture;
  60962. /**
  60963. * Disposes of the depth renderer.
  60964. */
  60965. dispose(): void;
  60966. }
  60967. }
  60968. declare module BABYLON {
  60969. interface Scene {
  60970. /** @hidden (Backing field) */
  60971. _depthRenderer: {
  60972. [id: string]: DepthRenderer;
  60973. };
  60974. /**
  60975. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60976. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60977. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60978. * @returns the created depth renderer
  60979. */
  60980. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60981. /**
  60982. * Disables a depth renderer for a given camera
  60983. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60984. */
  60985. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60986. }
  60987. /**
  60988. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60989. * in several rendering techniques.
  60990. */
  60991. export class DepthRendererSceneComponent implements ISceneComponent {
  60992. /**
  60993. * The component name helpfull to identify the component in the list of scene components.
  60994. */
  60995. readonly name: string;
  60996. /**
  60997. * The scene the component belongs to.
  60998. */
  60999. scene: Scene;
  61000. /**
  61001. * Creates a new instance of the component for the given scene
  61002. * @param scene Defines the scene to register the component in
  61003. */
  61004. constructor(scene: Scene);
  61005. /**
  61006. * Registers the component in a given scene
  61007. */
  61008. register(): void;
  61009. /**
  61010. * Rebuilds the elements related to this component in case of
  61011. * context lost for instance.
  61012. */
  61013. rebuild(): void;
  61014. /**
  61015. * Disposes the component and the associated ressources
  61016. */
  61017. dispose(): void;
  61018. private _gatherRenderTargets;
  61019. private _gatherActiveCameraRenderTargets;
  61020. }
  61021. }
  61022. declare module BABYLON {
  61023. /** @hidden */
  61024. export var outlinePixelShader: {
  61025. name: string;
  61026. shader: string;
  61027. };
  61028. }
  61029. declare module BABYLON {
  61030. /** @hidden */
  61031. export var outlineVertexShader: {
  61032. name: string;
  61033. shader: string;
  61034. };
  61035. }
  61036. declare module BABYLON {
  61037. interface Scene {
  61038. /** @hidden */
  61039. _outlineRenderer: OutlineRenderer;
  61040. /**
  61041. * Gets the outline renderer associated with the scene
  61042. * @returns a OutlineRenderer
  61043. */
  61044. getOutlineRenderer(): OutlineRenderer;
  61045. }
  61046. interface AbstractMesh {
  61047. /** @hidden (Backing field) */
  61048. _renderOutline: boolean;
  61049. /**
  61050. * Gets or sets a boolean indicating if the outline must be rendered as well
  61051. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61052. */
  61053. renderOutline: boolean;
  61054. /** @hidden (Backing field) */
  61055. _renderOverlay: boolean;
  61056. /**
  61057. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61058. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61059. */
  61060. renderOverlay: boolean;
  61061. }
  61062. /**
  61063. * This class is responsible to draw bothe outline/overlay of meshes.
  61064. * It should not be used directly but through the available method on mesh.
  61065. */
  61066. export class OutlineRenderer implements ISceneComponent {
  61067. /**
  61068. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61069. */
  61070. private static _StencilReference;
  61071. /**
  61072. * The name of the component. Each component must have a unique name.
  61073. */
  61074. name: string;
  61075. /**
  61076. * The scene the component belongs to.
  61077. */
  61078. scene: Scene;
  61079. /**
  61080. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61081. */
  61082. zOffset: number;
  61083. private _engine;
  61084. private _effect;
  61085. private _cachedDefines;
  61086. private _savedDepthWrite;
  61087. /**
  61088. * Instantiates a new outline renderer. (There could be only one per scene).
  61089. * @param scene Defines the scene it belongs to
  61090. */
  61091. constructor(scene: Scene);
  61092. /**
  61093. * Register the component to one instance of a scene.
  61094. */
  61095. register(): void;
  61096. /**
  61097. * Rebuilds the elements related to this component in case of
  61098. * context lost for instance.
  61099. */
  61100. rebuild(): void;
  61101. /**
  61102. * Disposes the component and the associated ressources.
  61103. */
  61104. dispose(): void;
  61105. /**
  61106. * Renders the outline in the canvas.
  61107. * @param subMesh Defines the sumesh to render
  61108. * @param batch Defines the batch of meshes in case of instances
  61109. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61110. */
  61111. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61112. /**
  61113. * Returns whether or not the outline renderer is ready for a given submesh.
  61114. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61115. * @param subMesh Defines the submesh to check readyness for
  61116. * @param useInstances Defines wheter wee are trying to render instances or not
  61117. * @returns true if ready otherwise false
  61118. */
  61119. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61120. private _beforeRenderingMesh;
  61121. private _afterRenderingMesh;
  61122. }
  61123. }
  61124. declare module BABYLON {
  61125. /**
  61126. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61127. * @see http://doc.babylonjs.com/babylon101/sprites
  61128. */
  61129. export class SpritePackedManager extends SpriteManager {
  61130. /** defines the packed manager's name */
  61131. name: string;
  61132. /**
  61133. * Creates a new sprite manager from a packed sprite sheet
  61134. * @param name defines the manager's name
  61135. * @param imgUrl defines the sprite sheet url
  61136. * @param capacity defines the maximum allowed number of sprites
  61137. * @param scene defines the hosting scene
  61138. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61139. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61140. * @param samplingMode defines the smapling mode to use with spritesheet
  61141. * @param fromPacked set to true; do not alter
  61142. */
  61143. constructor(
  61144. /** defines the packed manager's name */
  61145. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61146. }
  61147. }
  61148. declare module BABYLON {
  61149. /**
  61150. * Defines the list of states available for a task inside a AssetsManager
  61151. */
  61152. export enum AssetTaskState {
  61153. /**
  61154. * Initialization
  61155. */
  61156. INIT = 0,
  61157. /**
  61158. * Running
  61159. */
  61160. RUNNING = 1,
  61161. /**
  61162. * Done
  61163. */
  61164. DONE = 2,
  61165. /**
  61166. * Error
  61167. */
  61168. ERROR = 3
  61169. }
  61170. /**
  61171. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61172. */
  61173. export abstract class AbstractAssetTask {
  61174. /**
  61175. * Task name
  61176. */ name: string;
  61177. /**
  61178. * Callback called when the task is successful
  61179. */
  61180. onSuccess: (task: any) => void;
  61181. /**
  61182. * Callback called when the task is not successful
  61183. */
  61184. onError: (task: any, message?: string, exception?: any) => void;
  61185. /**
  61186. * Creates a new AssetsManager
  61187. * @param name defines the name of the task
  61188. */
  61189. constructor(
  61190. /**
  61191. * Task name
  61192. */ name: string);
  61193. private _isCompleted;
  61194. private _taskState;
  61195. private _errorObject;
  61196. /**
  61197. * Get if the task is completed
  61198. */
  61199. readonly isCompleted: boolean;
  61200. /**
  61201. * Gets the current state of the task
  61202. */
  61203. readonly taskState: AssetTaskState;
  61204. /**
  61205. * Gets the current error object (if task is in error)
  61206. */
  61207. readonly errorObject: {
  61208. message?: string;
  61209. exception?: any;
  61210. };
  61211. /**
  61212. * Internal only
  61213. * @hidden
  61214. */
  61215. _setErrorObject(message?: string, exception?: any): void;
  61216. /**
  61217. * Execute the current task
  61218. * @param scene defines the scene where you want your assets to be loaded
  61219. * @param onSuccess is a callback called when the task is successfully executed
  61220. * @param onError is a callback called if an error occurs
  61221. */
  61222. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61223. /**
  61224. * Execute the current task
  61225. * @param scene defines the scene where you want your assets to be loaded
  61226. * @param onSuccess is a callback called when the task is successfully executed
  61227. * @param onError is a callback called if an error occurs
  61228. */
  61229. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61230. /**
  61231. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61232. * This can be used with failed tasks that have the reason for failure fixed.
  61233. */
  61234. reset(): void;
  61235. private onErrorCallback;
  61236. private onDoneCallback;
  61237. }
  61238. /**
  61239. * Define the interface used by progress events raised during assets loading
  61240. */
  61241. export interface IAssetsProgressEvent {
  61242. /**
  61243. * Defines the number of remaining tasks to process
  61244. */
  61245. remainingCount: number;
  61246. /**
  61247. * Defines the total number of tasks
  61248. */
  61249. totalCount: number;
  61250. /**
  61251. * Defines the task that was just processed
  61252. */
  61253. task: AbstractAssetTask;
  61254. }
  61255. /**
  61256. * Class used to share progress information about assets loading
  61257. */
  61258. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61259. /**
  61260. * Defines the number of remaining tasks to process
  61261. */
  61262. remainingCount: number;
  61263. /**
  61264. * Defines the total number of tasks
  61265. */
  61266. totalCount: number;
  61267. /**
  61268. * Defines the task that was just processed
  61269. */
  61270. task: AbstractAssetTask;
  61271. /**
  61272. * Creates a AssetsProgressEvent
  61273. * @param remainingCount defines the number of remaining tasks to process
  61274. * @param totalCount defines the total number of tasks
  61275. * @param task defines the task that was just processed
  61276. */
  61277. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61278. }
  61279. /**
  61280. * Define a task used by AssetsManager to load meshes
  61281. */
  61282. export class MeshAssetTask extends AbstractAssetTask {
  61283. /**
  61284. * Defines the name of the task
  61285. */
  61286. name: string;
  61287. /**
  61288. * Defines the list of mesh's names you want to load
  61289. */
  61290. meshesNames: any;
  61291. /**
  61292. * Defines the root url to use as a base to load your meshes and associated resources
  61293. */
  61294. rootUrl: string;
  61295. /**
  61296. * Defines the filename of the scene to load from
  61297. */
  61298. sceneFilename: string;
  61299. /**
  61300. * Gets the list of loaded meshes
  61301. */
  61302. loadedMeshes: Array<AbstractMesh>;
  61303. /**
  61304. * Gets the list of loaded particle systems
  61305. */
  61306. loadedParticleSystems: Array<IParticleSystem>;
  61307. /**
  61308. * Gets the list of loaded skeletons
  61309. */
  61310. loadedSkeletons: Array<Skeleton>;
  61311. /**
  61312. * Gets the list of loaded animation groups
  61313. */
  61314. loadedAnimationGroups: Array<AnimationGroup>;
  61315. /**
  61316. * Callback called when the task is successful
  61317. */
  61318. onSuccess: (task: MeshAssetTask) => void;
  61319. /**
  61320. * Callback called when the task is successful
  61321. */
  61322. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61323. /**
  61324. * Creates a new MeshAssetTask
  61325. * @param name defines the name of the task
  61326. * @param meshesNames defines the list of mesh's names you want to load
  61327. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61328. * @param sceneFilename defines the filename of the scene to load from
  61329. */
  61330. constructor(
  61331. /**
  61332. * Defines the name of the task
  61333. */
  61334. name: string,
  61335. /**
  61336. * Defines the list of mesh's names you want to load
  61337. */
  61338. meshesNames: any,
  61339. /**
  61340. * Defines the root url to use as a base to load your meshes and associated resources
  61341. */
  61342. rootUrl: string,
  61343. /**
  61344. * Defines the filename of the scene to load from
  61345. */
  61346. sceneFilename: string);
  61347. /**
  61348. * Execute the current task
  61349. * @param scene defines the scene where you want your assets to be loaded
  61350. * @param onSuccess is a callback called when the task is successfully executed
  61351. * @param onError is a callback called if an error occurs
  61352. */
  61353. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61354. }
  61355. /**
  61356. * Define a task used by AssetsManager to load text content
  61357. */
  61358. export class TextFileAssetTask extends AbstractAssetTask {
  61359. /**
  61360. * Defines the name of the task
  61361. */
  61362. name: string;
  61363. /**
  61364. * Defines the location of the file to load
  61365. */
  61366. url: string;
  61367. /**
  61368. * Gets the loaded text string
  61369. */
  61370. text: string;
  61371. /**
  61372. * Callback called when the task is successful
  61373. */
  61374. onSuccess: (task: TextFileAssetTask) => void;
  61375. /**
  61376. * Callback called when the task is successful
  61377. */
  61378. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61379. /**
  61380. * Creates a new TextFileAssetTask object
  61381. * @param name defines the name of the task
  61382. * @param url defines the location of the file to load
  61383. */
  61384. constructor(
  61385. /**
  61386. * Defines the name of the task
  61387. */
  61388. name: string,
  61389. /**
  61390. * Defines the location of the file to load
  61391. */
  61392. url: string);
  61393. /**
  61394. * Execute the current task
  61395. * @param scene defines the scene where you want your assets to be loaded
  61396. * @param onSuccess is a callback called when the task is successfully executed
  61397. * @param onError is a callback called if an error occurs
  61398. */
  61399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61400. }
  61401. /**
  61402. * Define a task used by AssetsManager to load binary data
  61403. */
  61404. export class BinaryFileAssetTask extends AbstractAssetTask {
  61405. /**
  61406. * Defines the name of the task
  61407. */
  61408. name: string;
  61409. /**
  61410. * Defines the location of the file to load
  61411. */
  61412. url: string;
  61413. /**
  61414. * Gets the lodaded data (as an array buffer)
  61415. */
  61416. data: ArrayBuffer;
  61417. /**
  61418. * Callback called when the task is successful
  61419. */
  61420. onSuccess: (task: BinaryFileAssetTask) => void;
  61421. /**
  61422. * Callback called when the task is successful
  61423. */
  61424. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61425. /**
  61426. * Creates a new BinaryFileAssetTask object
  61427. * @param name defines the name of the new task
  61428. * @param url defines the location of the file to load
  61429. */
  61430. constructor(
  61431. /**
  61432. * Defines the name of the task
  61433. */
  61434. name: string,
  61435. /**
  61436. * Defines the location of the file to load
  61437. */
  61438. url: string);
  61439. /**
  61440. * Execute the current task
  61441. * @param scene defines the scene where you want your assets to be loaded
  61442. * @param onSuccess is a callback called when the task is successfully executed
  61443. * @param onError is a callback called if an error occurs
  61444. */
  61445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61446. }
  61447. /**
  61448. * Define a task used by AssetsManager to load images
  61449. */
  61450. export class ImageAssetTask extends AbstractAssetTask {
  61451. /**
  61452. * Defines the name of the task
  61453. */
  61454. name: string;
  61455. /**
  61456. * Defines the location of the image to load
  61457. */
  61458. url: string;
  61459. /**
  61460. * Gets the loaded images
  61461. */
  61462. image: HTMLImageElement;
  61463. /**
  61464. * Callback called when the task is successful
  61465. */
  61466. onSuccess: (task: ImageAssetTask) => void;
  61467. /**
  61468. * Callback called when the task is successful
  61469. */
  61470. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61471. /**
  61472. * Creates a new ImageAssetTask
  61473. * @param name defines the name of the task
  61474. * @param url defines the location of the image to load
  61475. */
  61476. constructor(
  61477. /**
  61478. * Defines the name of the task
  61479. */
  61480. name: string,
  61481. /**
  61482. * Defines the location of the image to load
  61483. */
  61484. url: string);
  61485. /**
  61486. * Execute the current task
  61487. * @param scene defines the scene where you want your assets to be loaded
  61488. * @param onSuccess is a callback called when the task is successfully executed
  61489. * @param onError is a callback called if an error occurs
  61490. */
  61491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61492. }
  61493. /**
  61494. * Defines the interface used by texture loading tasks
  61495. */
  61496. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61497. /**
  61498. * Gets the loaded texture
  61499. */
  61500. texture: TEX;
  61501. }
  61502. /**
  61503. * Define a task used by AssetsManager to load 2D textures
  61504. */
  61505. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61506. /**
  61507. * Defines the name of the task
  61508. */
  61509. name: string;
  61510. /**
  61511. * Defines the location of the file to load
  61512. */
  61513. url: string;
  61514. /**
  61515. * Defines if mipmap should not be generated (default is false)
  61516. */
  61517. noMipmap?: boolean | undefined;
  61518. /**
  61519. * Defines if texture must be inverted on Y axis (default is false)
  61520. */
  61521. invertY?: boolean | undefined;
  61522. /**
  61523. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61524. */
  61525. samplingMode: number;
  61526. /**
  61527. * Gets the loaded texture
  61528. */
  61529. texture: Texture;
  61530. /**
  61531. * Callback called when the task is successful
  61532. */
  61533. onSuccess: (task: TextureAssetTask) => void;
  61534. /**
  61535. * Callback called when the task is successful
  61536. */
  61537. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61538. /**
  61539. * Creates a new TextureAssetTask object
  61540. * @param name defines the name of the task
  61541. * @param url defines the location of the file to load
  61542. * @param noMipmap defines if mipmap should not be generated (default is false)
  61543. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61544. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61545. */
  61546. constructor(
  61547. /**
  61548. * Defines the name of the task
  61549. */
  61550. name: string,
  61551. /**
  61552. * Defines the location of the file to load
  61553. */
  61554. url: string,
  61555. /**
  61556. * Defines if mipmap should not be generated (default is false)
  61557. */
  61558. noMipmap?: boolean | undefined,
  61559. /**
  61560. * Defines if texture must be inverted on Y axis (default is false)
  61561. */
  61562. invertY?: boolean | undefined,
  61563. /**
  61564. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61565. */
  61566. samplingMode?: number);
  61567. /**
  61568. * Execute the current task
  61569. * @param scene defines the scene where you want your assets to be loaded
  61570. * @param onSuccess is a callback called when the task is successfully executed
  61571. * @param onError is a callback called if an error occurs
  61572. */
  61573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61574. }
  61575. /**
  61576. * Define a task used by AssetsManager to load cube textures
  61577. */
  61578. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61579. /**
  61580. * Defines the name of the task
  61581. */
  61582. name: string;
  61583. /**
  61584. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61585. */
  61586. url: string;
  61587. /**
  61588. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61589. */
  61590. extensions?: string[] | undefined;
  61591. /**
  61592. * Defines if mipmaps should not be generated (default is false)
  61593. */
  61594. noMipmap?: boolean | undefined;
  61595. /**
  61596. * Defines the explicit list of files (undefined by default)
  61597. */
  61598. files?: string[] | undefined;
  61599. /**
  61600. * Gets the loaded texture
  61601. */
  61602. texture: CubeTexture;
  61603. /**
  61604. * Callback called when the task is successful
  61605. */
  61606. onSuccess: (task: CubeTextureAssetTask) => void;
  61607. /**
  61608. * Callback called when the task is successful
  61609. */
  61610. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61611. /**
  61612. * Creates a new CubeTextureAssetTask
  61613. * @param name defines the name of the task
  61614. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61615. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61616. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61617. * @param files defines the explicit list of files (undefined by default)
  61618. */
  61619. constructor(
  61620. /**
  61621. * Defines the name of the task
  61622. */
  61623. name: string,
  61624. /**
  61625. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61626. */
  61627. url: string,
  61628. /**
  61629. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61630. */
  61631. extensions?: string[] | undefined,
  61632. /**
  61633. * Defines if mipmaps should not be generated (default is false)
  61634. */
  61635. noMipmap?: boolean | undefined,
  61636. /**
  61637. * Defines the explicit list of files (undefined by default)
  61638. */
  61639. files?: string[] | undefined);
  61640. /**
  61641. * Execute the current task
  61642. * @param scene defines the scene where you want your assets to be loaded
  61643. * @param onSuccess is a callback called when the task is successfully executed
  61644. * @param onError is a callback called if an error occurs
  61645. */
  61646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61647. }
  61648. /**
  61649. * Define a task used by AssetsManager to load HDR cube textures
  61650. */
  61651. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61652. /**
  61653. * Defines the name of the task
  61654. */
  61655. name: string;
  61656. /**
  61657. * Defines the location of the file to load
  61658. */
  61659. url: string;
  61660. /**
  61661. * Defines the desired size (the more it increases the longer the generation will be)
  61662. */
  61663. size: number;
  61664. /**
  61665. * Defines if mipmaps should not be generated (default is false)
  61666. */
  61667. noMipmap: boolean;
  61668. /**
  61669. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61670. */
  61671. generateHarmonics: boolean;
  61672. /**
  61673. * 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)
  61674. */
  61675. gammaSpace: boolean;
  61676. /**
  61677. * Internal Use Only
  61678. */
  61679. reserved: boolean;
  61680. /**
  61681. * Gets the loaded texture
  61682. */
  61683. texture: HDRCubeTexture;
  61684. /**
  61685. * Callback called when the task is successful
  61686. */
  61687. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61688. /**
  61689. * Callback called when the task is successful
  61690. */
  61691. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61692. /**
  61693. * Creates a new HDRCubeTextureAssetTask object
  61694. * @param name defines the name of the task
  61695. * @param url defines the location of the file to load
  61696. * @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.
  61697. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61698. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61699. * @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)
  61700. * @param reserved Internal use only
  61701. */
  61702. constructor(
  61703. /**
  61704. * Defines the name of the task
  61705. */
  61706. name: string,
  61707. /**
  61708. * Defines the location of the file to load
  61709. */
  61710. url: string,
  61711. /**
  61712. * Defines the desired size (the more it increases the longer the generation will be)
  61713. */
  61714. size: number,
  61715. /**
  61716. * Defines if mipmaps should not be generated (default is false)
  61717. */
  61718. noMipmap?: boolean,
  61719. /**
  61720. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61721. */
  61722. generateHarmonics?: boolean,
  61723. /**
  61724. * 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)
  61725. */
  61726. gammaSpace?: boolean,
  61727. /**
  61728. * Internal Use Only
  61729. */
  61730. reserved?: boolean);
  61731. /**
  61732. * Execute the current task
  61733. * @param scene defines the scene where you want your assets to be loaded
  61734. * @param onSuccess is a callback called when the task is successfully executed
  61735. * @param onError is a callback called if an error occurs
  61736. */
  61737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61738. }
  61739. /**
  61740. * Define a task used by AssetsManager to load Equirectangular cube textures
  61741. */
  61742. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61743. /**
  61744. * Defines the name of the task
  61745. */
  61746. name: string;
  61747. /**
  61748. * Defines the location of the file to load
  61749. */
  61750. url: string;
  61751. /**
  61752. * Defines the desired size (the more it increases the longer the generation will be)
  61753. */
  61754. size: number;
  61755. /**
  61756. * Defines if mipmaps should not be generated (default is false)
  61757. */
  61758. noMipmap: boolean;
  61759. /**
  61760. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61761. * but the standard material would require them in Gamma space) (default is true)
  61762. */
  61763. gammaSpace: boolean;
  61764. /**
  61765. * Gets the loaded texture
  61766. */
  61767. texture: EquiRectangularCubeTexture;
  61768. /**
  61769. * Callback called when the task is successful
  61770. */
  61771. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61772. /**
  61773. * Callback called when the task is successful
  61774. */
  61775. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61776. /**
  61777. * Creates a new EquiRectangularCubeTextureAssetTask object
  61778. * @param name defines the name of the task
  61779. * @param url defines the location of the file to load
  61780. * @param size defines the desired size (the more it increases the longer the generation will be)
  61781. * If the size is omitted this implies you are using a preprocessed cubemap.
  61782. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61783. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61784. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61785. * (default is true)
  61786. */
  61787. constructor(
  61788. /**
  61789. * Defines the name of the task
  61790. */
  61791. name: string,
  61792. /**
  61793. * Defines the location of the file to load
  61794. */
  61795. url: string,
  61796. /**
  61797. * Defines the desired size (the more it increases the longer the generation will be)
  61798. */
  61799. size: number,
  61800. /**
  61801. * Defines if mipmaps should not be generated (default is false)
  61802. */
  61803. noMipmap?: boolean,
  61804. /**
  61805. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61806. * but the standard material would require them in Gamma space) (default is true)
  61807. */
  61808. gammaSpace?: boolean);
  61809. /**
  61810. * Execute the current task
  61811. * @param scene defines the scene where you want your assets to be loaded
  61812. * @param onSuccess is a callback called when the task is successfully executed
  61813. * @param onError is a callback called if an error occurs
  61814. */
  61815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61816. }
  61817. /**
  61818. * This class can be used to easily import assets into a scene
  61819. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61820. */
  61821. export class AssetsManager {
  61822. private _scene;
  61823. private _isLoading;
  61824. protected _tasks: AbstractAssetTask[];
  61825. protected _waitingTasksCount: number;
  61826. protected _totalTasksCount: number;
  61827. /**
  61828. * Callback called when all tasks are processed
  61829. */
  61830. onFinish: (tasks: AbstractAssetTask[]) => void;
  61831. /**
  61832. * Callback called when a task is successful
  61833. */
  61834. onTaskSuccess: (task: AbstractAssetTask) => void;
  61835. /**
  61836. * Callback called when a task had an error
  61837. */
  61838. onTaskError: (task: AbstractAssetTask) => void;
  61839. /**
  61840. * Callback called when a task is done (whatever the result is)
  61841. */
  61842. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61843. /**
  61844. * Observable called when all tasks are processed
  61845. */
  61846. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61847. /**
  61848. * Observable called when a task had an error
  61849. */
  61850. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61851. /**
  61852. * Observable called when all tasks were executed
  61853. */
  61854. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61855. /**
  61856. * Observable called when a task is done (whatever the result is)
  61857. */
  61858. onProgressObservable: Observable<IAssetsProgressEvent>;
  61859. /**
  61860. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61862. */
  61863. useDefaultLoadingScreen: boolean;
  61864. /**
  61865. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61866. * when all assets have been downloaded.
  61867. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61868. */
  61869. autoHideLoadingUI: boolean;
  61870. /**
  61871. * Creates a new AssetsManager
  61872. * @param scene defines the scene to work on
  61873. */
  61874. constructor(scene: Scene);
  61875. /**
  61876. * Add a MeshAssetTask to the list of active tasks
  61877. * @param taskName defines the name of the new task
  61878. * @param meshesNames defines the name of meshes to load
  61879. * @param rootUrl defines the root url to use to locate files
  61880. * @param sceneFilename defines the filename of the scene file
  61881. * @returns a new MeshAssetTask object
  61882. */
  61883. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61884. /**
  61885. * Add a TextFileAssetTask to the list of active tasks
  61886. * @param taskName defines the name of the new task
  61887. * @param url defines the url of the file to load
  61888. * @returns a new TextFileAssetTask object
  61889. */
  61890. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61891. /**
  61892. * Add a BinaryFileAssetTask to the list of active tasks
  61893. * @param taskName defines the name of the new task
  61894. * @param url defines the url of the file to load
  61895. * @returns a new BinaryFileAssetTask object
  61896. */
  61897. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61898. /**
  61899. * Add a ImageAssetTask to the list of active tasks
  61900. * @param taskName defines the name of the new task
  61901. * @param url defines the url of the file to load
  61902. * @returns a new ImageAssetTask object
  61903. */
  61904. addImageTask(taskName: string, url: string): ImageAssetTask;
  61905. /**
  61906. * Add a TextureAssetTask to the list of active tasks
  61907. * @param taskName defines the name of the new task
  61908. * @param url defines the url of the file to load
  61909. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61910. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61911. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61912. * @returns a new TextureAssetTask object
  61913. */
  61914. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61915. /**
  61916. * Add a CubeTextureAssetTask to the list of active tasks
  61917. * @param taskName defines the name of the new task
  61918. * @param url defines the url of the file to load
  61919. * @param extensions defines the extension to use to load the cube map (can be null)
  61920. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61921. * @param files defines the list of files to load (can be null)
  61922. * @returns a new CubeTextureAssetTask object
  61923. */
  61924. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61925. /**
  61926. *
  61927. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61928. * @param taskName defines the name of the new task
  61929. * @param url defines the url of the file to load
  61930. * @param size defines the size you want for the cubemap (can be null)
  61931. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61932. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61933. * @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)
  61934. * @param reserved Internal use only
  61935. * @returns a new HDRCubeTextureAssetTask object
  61936. */
  61937. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61938. /**
  61939. *
  61940. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61941. * @param taskName defines the name of the new task
  61942. * @param url defines the url of the file to load
  61943. * @param size defines the size you want for the cubemap (can be null)
  61944. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61945. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61946. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61947. * @returns a new EquiRectangularCubeTextureAssetTask object
  61948. */
  61949. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61950. /**
  61951. * Remove a task from the assets manager.
  61952. * @param task the task to remove
  61953. */
  61954. removeTask(task: AbstractAssetTask): void;
  61955. private _decreaseWaitingTasksCount;
  61956. private _runTask;
  61957. /**
  61958. * Reset the AssetsManager and remove all tasks
  61959. * @return the current instance of the AssetsManager
  61960. */
  61961. reset(): AssetsManager;
  61962. /**
  61963. * Start the loading process
  61964. * @return the current instance of the AssetsManager
  61965. */
  61966. load(): AssetsManager;
  61967. /**
  61968. * Start the loading process as an async operation
  61969. * @return a promise returning the list of failed tasks
  61970. */
  61971. loadAsync(): Promise<void>;
  61972. }
  61973. }
  61974. declare module BABYLON {
  61975. /**
  61976. * Wrapper class for promise with external resolve and reject.
  61977. */
  61978. export class Deferred<T> {
  61979. /**
  61980. * The promise associated with this deferred object.
  61981. */
  61982. readonly promise: Promise<T>;
  61983. private _resolve;
  61984. private _reject;
  61985. /**
  61986. * The resolve method of the promise associated with this deferred object.
  61987. */
  61988. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61989. /**
  61990. * The reject method of the promise associated with this deferred object.
  61991. */
  61992. readonly reject: (reason?: any) => void;
  61993. /**
  61994. * Constructor for this deferred object.
  61995. */
  61996. constructor();
  61997. }
  61998. }
  61999. declare module BABYLON {
  62000. /**
  62001. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62002. */
  62003. export class MeshExploder {
  62004. private _centerMesh;
  62005. private _meshes;
  62006. private _meshesOrigins;
  62007. private _toCenterVectors;
  62008. private _scaledDirection;
  62009. private _newPosition;
  62010. private _centerPosition;
  62011. /**
  62012. * Explodes meshes from a center mesh.
  62013. * @param meshes The meshes to explode.
  62014. * @param centerMesh The mesh to be center of explosion.
  62015. */
  62016. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62017. private _setCenterMesh;
  62018. /**
  62019. * Get class name
  62020. * @returns "MeshExploder"
  62021. */
  62022. getClassName(): string;
  62023. /**
  62024. * "Exploded meshes"
  62025. * @returns Array of meshes with the centerMesh at index 0.
  62026. */
  62027. getMeshes(): Array<Mesh>;
  62028. /**
  62029. * Explodes meshes giving a specific direction
  62030. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62031. */
  62032. explode(direction?: number): void;
  62033. }
  62034. }
  62035. declare module BABYLON {
  62036. /**
  62037. * Class used to help managing file picking and drag'n'drop
  62038. */
  62039. export class FilesInput {
  62040. /**
  62041. * List of files ready to be loaded
  62042. */
  62043. static readonly FilesToLoad: {
  62044. [key: string]: File;
  62045. };
  62046. /**
  62047. * Callback called when a file is processed
  62048. */
  62049. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62050. private _engine;
  62051. private _currentScene;
  62052. private _sceneLoadedCallback;
  62053. private _progressCallback;
  62054. private _additionalRenderLoopLogicCallback;
  62055. private _textureLoadingCallback;
  62056. private _startingProcessingFilesCallback;
  62057. private _onReloadCallback;
  62058. private _errorCallback;
  62059. private _elementToMonitor;
  62060. private _sceneFileToLoad;
  62061. private _filesToLoad;
  62062. /**
  62063. * Creates a new FilesInput
  62064. * @param engine defines the rendering engine
  62065. * @param scene defines the hosting scene
  62066. * @param sceneLoadedCallback callback called when scene is loaded
  62067. * @param progressCallback callback called to track progress
  62068. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62069. * @param textureLoadingCallback callback called when a texture is loading
  62070. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62071. * @param onReloadCallback callback called when a reload is requested
  62072. * @param errorCallback callback call if an error occurs
  62073. */
  62074. 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);
  62075. private _dragEnterHandler;
  62076. private _dragOverHandler;
  62077. private _dropHandler;
  62078. /**
  62079. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62080. * @param elementToMonitor defines the DOM element to track
  62081. */
  62082. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62083. /**
  62084. * Release all associated resources
  62085. */
  62086. dispose(): void;
  62087. private renderFunction;
  62088. private drag;
  62089. private drop;
  62090. private _traverseFolder;
  62091. private _processFiles;
  62092. /**
  62093. * Load files from a drop event
  62094. * @param event defines the drop event to use as source
  62095. */
  62096. loadFiles(event: any): void;
  62097. private _processReload;
  62098. /**
  62099. * Reload the current scene from the loaded files
  62100. */
  62101. reload(): void;
  62102. }
  62103. }
  62104. declare module BABYLON {
  62105. /**
  62106. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62108. */
  62109. export class SceneOptimization {
  62110. /**
  62111. * Defines the priority of this optimization (0 by default which means first in the list)
  62112. */
  62113. priority: number;
  62114. /**
  62115. * Gets a string describing the action executed by the current optimization
  62116. * @returns description string
  62117. */
  62118. getDescription(): string;
  62119. /**
  62120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62121. * @param scene defines the current scene where to apply this optimization
  62122. * @param optimizer defines the current optimizer
  62123. * @returns true if everything that can be done was applied
  62124. */
  62125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62126. /**
  62127. * Creates the SceneOptimization object
  62128. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62129. * @param desc defines the description associated with the optimization
  62130. */
  62131. constructor(
  62132. /**
  62133. * Defines the priority of this optimization (0 by default which means first in the list)
  62134. */
  62135. priority?: number);
  62136. }
  62137. /**
  62138. * Defines an optimization used to reduce the size of render target textures
  62139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62140. */
  62141. export class TextureOptimization extends SceneOptimization {
  62142. /**
  62143. * Defines the priority of this optimization (0 by default which means first in the list)
  62144. */
  62145. priority: number;
  62146. /**
  62147. * 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
  62148. */
  62149. maximumSize: number;
  62150. /**
  62151. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62152. */
  62153. step: number;
  62154. /**
  62155. * Gets a string describing the action executed by the current optimization
  62156. * @returns description string
  62157. */
  62158. getDescription(): string;
  62159. /**
  62160. * Creates the TextureOptimization object
  62161. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62162. * @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
  62163. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62164. */
  62165. constructor(
  62166. /**
  62167. * Defines the priority of this optimization (0 by default which means first in the list)
  62168. */
  62169. priority?: number,
  62170. /**
  62171. * 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
  62172. */
  62173. maximumSize?: number,
  62174. /**
  62175. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62176. */
  62177. step?: number);
  62178. /**
  62179. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62180. * @param scene defines the current scene where to apply this optimization
  62181. * @param optimizer defines the current optimizer
  62182. * @returns true if everything that can be done was applied
  62183. */
  62184. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62185. }
  62186. /**
  62187. * Defines an optimization used to increase or decrease the rendering resolution
  62188. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62189. */
  62190. export class HardwareScalingOptimization extends SceneOptimization {
  62191. /**
  62192. * Defines the priority of this optimization (0 by default which means first in the list)
  62193. */
  62194. priority: number;
  62195. /**
  62196. * Defines the maximum scale to use (2 by default)
  62197. */
  62198. maximumScale: number;
  62199. /**
  62200. * Defines the step to use between two passes (0.5 by default)
  62201. */
  62202. step: number;
  62203. private _currentScale;
  62204. private _directionOffset;
  62205. /**
  62206. * Gets a string describing the action executed by the current optimization
  62207. * @return description string
  62208. */
  62209. getDescription(): string;
  62210. /**
  62211. * Creates the HardwareScalingOptimization object
  62212. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62213. * @param maximumScale defines the maximum scale to use (2 by default)
  62214. * @param step defines the step to use between two passes (0.5 by default)
  62215. */
  62216. constructor(
  62217. /**
  62218. * Defines the priority of this optimization (0 by default which means first in the list)
  62219. */
  62220. priority?: number,
  62221. /**
  62222. * Defines the maximum scale to use (2 by default)
  62223. */
  62224. maximumScale?: number,
  62225. /**
  62226. * Defines the step to use between two passes (0.5 by default)
  62227. */
  62228. step?: number);
  62229. /**
  62230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62231. * @param scene defines the current scene where to apply this optimization
  62232. * @param optimizer defines the current optimizer
  62233. * @returns true if everything that can be done was applied
  62234. */
  62235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62236. }
  62237. /**
  62238. * Defines an optimization used to remove shadows
  62239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62240. */
  62241. export class ShadowsOptimization extends SceneOptimization {
  62242. /**
  62243. * Gets a string describing the action executed by the current optimization
  62244. * @return description string
  62245. */
  62246. getDescription(): string;
  62247. /**
  62248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62249. * @param scene defines the current scene where to apply this optimization
  62250. * @param optimizer defines the current optimizer
  62251. * @returns true if everything that can be done was applied
  62252. */
  62253. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62254. }
  62255. /**
  62256. * Defines an optimization used to turn post-processes off
  62257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62258. */
  62259. export class PostProcessesOptimization extends SceneOptimization {
  62260. /**
  62261. * Gets a string describing the action executed by the current optimization
  62262. * @return description string
  62263. */
  62264. getDescription(): string;
  62265. /**
  62266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62267. * @param scene defines the current scene where to apply this optimization
  62268. * @param optimizer defines the current optimizer
  62269. * @returns true if everything that can be done was applied
  62270. */
  62271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62272. }
  62273. /**
  62274. * Defines an optimization used to turn lens flares off
  62275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62276. */
  62277. export class LensFlaresOptimization extends SceneOptimization {
  62278. /**
  62279. * Gets a string describing the action executed by the current optimization
  62280. * @return description string
  62281. */
  62282. getDescription(): string;
  62283. /**
  62284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62285. * @param scene defines the current scene where to apply this optimization
  62286. * @param optimizer defines the current optimizer
  62287. * @returns true if everything that can be done was applied
  62288. */
  62289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62290. }
  62291. /**
  62292. * Defines an optimization based on user defined callback.
  62293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62294. */
  62295. export class CustomOptimization extends SceneOptimization {
  62296. /**
  62297. * Callback called to apply the custom optimization.
  62298. */
  62299. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62300. /**
  62301. * Callback called to get custom description
  62302. */
  62303. onGetDescription: () => string;
  62304. /**
  62305. * Gets a string describing the action executed by the current optimization
  62306. * @returns description string
  62307. */
  62308. getDescription(): string;
  62309. /**
  62310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62311. * @param scene defines the current scene where to apply this optimization
  62312. * @param optimizer defines the current optimizer
  62313. * @returns true if everything that can be done was applied
  62314. */
  62315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62316. }
  62317. /**
  62318. * Defines an optimization used to turn particles off
  62319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62320. */
  62321. export class ParticlesOptimization extends SceneOptimization {
  62322. /**
  62323. * Gets a string describing the action executed by the current optimization
  62324. * @return description string
  62325. */
  62326. getDescription(): string;
  62327. /**
  62328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62329. * @param scene defines the current scene where to apply this optimization
  62330. * @param optimizer defines the current optimizer
  62331. * @returns true if everything that can be done was applied
  62332. */
  62333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62334. }
  62335. /**
  62336. * Defines an optimization used to turn render targets off
  62337. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62338. */
  62339. export class RenderTargetsOptimization extends SceneOptimization {
  62340. /**
  62341. * Gets a string describing the action executed by the current optimization
  62342. * @return description string
  62343. */
  62344. getDescription(): string;
  62345. /**
  62346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62347. * @param scene defines the current scene where to apply this optimization
  62348. * @param optimizer defines the current optimizer
  62349. * @returns true if everything that can be done was applied
  62350. */
  62351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62352. }
  62353. /**
  62354. * Defines an optimization used to merge meshes with compatible materials
  62355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62356. */
  62357. export class MergeMeshesOptimization extends SceneOptimization {
  62358. private static _UpdateSelectionTree;
  62359. /**
  62360. * Gets or sets a boolean which defines if optimization octree has to be updated
  62361. */
  62362. /**
  62363. * Gets or sets a boolean which defines if optimization octree has to be updated
  62364. */
  62365. static UpdateSelectionTree: boolean;
  62366. /**
  62367. * Gets a string describing the action executed by the current optimization
  62368. * @return description string
  62369. */
  62370. getDescription(): string;
  62371. private _canBeMerged;
  62372. /**
  62373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62374. * @param scene defines the current scene where to apply this optimization
  62375. * @param optimizer defines the current optimizer
  62376. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62377. * @returns true if everything that can be done was applied
  62378. */
  62379. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62380. }
  62381. /**
  62382. * Defines a list of options used by SceneOptimizer
  62383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62384. */
  62385. export class SceneOptimizerOptions {
  62386. /**
  62387. * Defines the target frame rate to reach (60 by default)
  62388. */
  62389. targetFrameRate: number;
  62390. /**
  62391. * Defines the interval between two checkes (2000ms by default)
  62392. */
  62393. trackerDuration: number;
  62394. /**
  62395. * Gets the list of optimizations to apply
  62396. */
  62397. optimizations: SceneOptimization[];
  62398. /**
  62399. * Creates a new list of options used by SceneOptimizer
  62400. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62401. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62402. */
  62403. constructor(
  62404. /**
  62405. * Defines the target frame rate to reach (60 by default)
  62406. */
  62407. targetFrameRate?: number,
  62408. /**
  62409. * Defines the interval between two checkes (2000ms by default)
  62410. */
  62411. trackerDuration?: number);
  62412. /**
  62413. * Add a new optimization
  62414. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62415. * @returns the current SceneOptimizerOptions
  62416. */
  62417. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62418. /**
  62419. * Add a new custom optimization
  62420. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62421. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62422. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62423. * @returns the current SceneOptimizerOptions
  62424. */
  62425. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62426. /**
  62427. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62428. * @param targetFrameRate defines the target frame rate (60 by default)
  62429. * @returns a SceneOptimizerOptions object
  62430. */
  62431. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62432. /**
  62433. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62434. * @param targetFrameRate defines the target frame rate (60 by default)
  62435. * @returns a SceneOptimizerOptions object
  62436. */
  62437. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62438. /**
  62439. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62440. * @param targetFrameRate defines the target frame rate (60 by default)
  62441. * @returns a SceneOptimizerOptions object
  62442. */
  62443. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62444. }
  62445. /**
  62446. * Class used to run optimizations in order to reach a target frame rate
  62447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62448. */
  62449. export class SceneOptimizer implements IDisposable {
  62450. private _isRunning;
  62451. private _options;
  62452. private _scene;
  62453. private _currentPriorityLevel;
  62454. private _targetFrameRate;
  62455. private _trackerDuration;
  62456. private _currentFrameRate;
  62457. private _sceneDisposeObserver;
  62458. private _improvementMode;
  62459. /**
  62460. * Defines an observable called when the optimizer reaches the target frame rate
  62461. */
  62462. onSuccessObservable: Observable<SceneOptimizer>;
  62463. /**
  62464. * Defines an observable called when the optimizer enables an optimization
  62465. */
  62466. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62467. /**
  62468. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62469. */
  62470. onFailureObservable: Observable<SceneOptimizer>;
  62471. /**
  62472. * Gets a boolean indicating if the optimizer is in improvement mode
  62473. */
  62474. readonly isInImprovementMode: boolean;
  62475. /**
  62476. * Gets the current priority level (0 at start)
  62477. */
  62478. readonly currentPriorityLevel: number;
  62479. /**
  62480. * Gets the current frame rate checked by the SceneOptimizer
  62481. */
  62482. readonly currentFrameRate: number;
  62483. /**
  62484. * Gets or sets the current target frame rate (60 by default)
  62485. */
  62486. /**
  62487. * Gets or sets the current target frame rate (60 by default)
  62488. */
  62489. targetFrameRate: number;
  62490. /**
  62491. * Gets or sets the current interval between two checks (every 2000ms by default)
  62492. */
  62493. /**
  62494. * Gets or sets the current interval between two checks (every 2000ms by default)
  62495. */
  62496. trackerDuration: number;
  62497. /**
  62498. * Gets the list of active optimizations
  62499. */
  62500. readonly optimizations: SceneOptimization[];
  62501. /**
  62502. * Creates a new SceneOptimizer
  62503. * @param scene defines the scene to work on
  62504. * @param options defines the options to use with the SceneOptimizer
  62505. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62506. * @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)
  62507. */
  62508. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62509. /**
  62510. * Stops the current optimizer
  62511. */
  62512. stop(): void;
  62513. /**
  62514. * Reset the optimizer to initial step (current priority level = 0)
  62515. */
  62516. reset(): void;
  62517. /**
  62518. * Start the optimizer. By default it will try to reach a specific framerate
  62519. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62520. */
  62521. start(): void;
  62522. private _checkCurrentState;
  62523. /**
  62524. * Release all resources
  62525. */
  62526. dispose(): void;
  62527. /**
  62528. * Helper function to create a SceneOptimizer with one single line of code
  62529. * @param scene defines the scene to work on
  62530. * @param options defines the options to use with the SceneOptimizer
  62531. * @param onSuccess defines a callback to call on success
  62532. * @param onFailure defines a callback to call on failure
  62533. * @returns the new SceneOptimizer object
  62534. */
  62535. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62536. }
  62537. }
  62538. declare module BABYLON {
  62539. /**
  62540. * Class used to serialize a scene into a string
  62541. */
  62542. export class SceneSerializer {
  62543. /**
  62544. * Clear cache used by a previous serialization
  62545. */
  62546. static ClearCache(): void;
  62547. /**
  62548. * Serialize a scene into a JSON compatible object
  62549. * @param scene defines the scene to serialize
  62550. * @returns a JSON compatible object
  62551. */
  62552. static Serialize(scene: Scene): any;
  62553. /**
  62554. * Serialize a mesh into a JSON compatible object
  62555. * @param toSerialize defines the mesh to serialize
  62556. * @param withParents defines if parents must be serialized as well
  62557. * @param withChildren defines if children must be serialized as well
  62558. * @returns a JSON compatible object
  62559. */
  62560. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62561. }
  62562. }
  62563. declare module BABYLON {
  62564. /**
  62565. * Class used to host texture specific utilities
  62566. */
  62567. export class TextureTools {
  62568. /**
  62569. * Uses the GPU to create a copy texture rescaled at a given size
  62570. * @param texture Texture to copy from
  62571. * @param width defines the desired width
  62572. * @param height defines the desired height
  62573. * @param useBilinearMode defines if bilinear mode has to be used
  62574. * @return the generated texture
  62575. */
  62576. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62577. }
  62578. }
  62579. declare module BABYLON {
  62580. /**
  62581. * This represents the different options available for the video capture.
  62582. */
  62583. export interface VideoRecorderOptions {
  62584. /** Defines the mime type of the video. */
  62585. mimeType: string;
  62586. /** Defines the FPS the video should be recorded at. */
  62587. fps: number;
  62588. /** Defines the chunk size for the recording data. */
  62589. recordChunckSize: number;
  62590. /** The audio tracks to attach to the recording. */
  62591. audioTracks?: MediaStreamTrack[];
  62592. }
  62593. /**
  62594. * This can help with recording videos from BabylonJS.
  62595. * This is based on the available WebRTC functionalities of the browser.
  62596. *
  62597. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62598. */
  62599. export class VideoRecorder {
  62600. private static readonly _defaultOptions;
  62601. /**
  62602. * Returns whether or not the VideoRecorder is available in your browser.
  62603. * @param engine Defines the Babylon Engine.
  62604. * @returns true if supported otherwise false.
  62605. */
  62606. static IsSupported(engine: Engine): boolean;
  62607. private readonly _options;
  62608. private _canvas;
  62609. private _mediaRecorder;
  62610. private _recordedChunks;
  62611. private _fileName;
  62612. private _resolve;
  62613. private _reject;
  62614. /**
  62615. * True when a recording is already in progress.
  62616. */
  62617. readonly isRecording: boolean;
  62618. /**
  62619. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62620. * @param engine Defines the BabylonJS Engine you wish to record.
  62621. * @param options Defines options that can be used to customize the capture.
  62622. */
  62623. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62624. /**
  62625. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62626. */
  62627. stopRecording(): void;
  62628. /**
  62629. * Starts recording the canvas for a max duration specified in parameters.
  62630. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62631. * If null no automatic download will start and you can rely on the promise to get the data back.
  62632. * @param maxDuration Defines the maximum recording time in seconds.
  62633. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62634. * @return A promise callback at the end of the recording with the video data in Blob.
  62635. */
  62636. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62637. /**
  62638. * Releases internal resources used during the recording.
  62639. */
  62640. dispose(): void;
  62641. private _handleDataAvailable;
  62642. private _handleError;
  62643. private _handleStop;
  62644. }
  62645. }
  62646. declare module BABYLON {
  62647. /**
  62648. * Class containing a set of static utilities functions for screenshots
  62649. */
  62650. export class ScreenshotTools {
  62651. /**
  62652. * Captures a screenshot of the current rendering
  62653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62654. * @param engine defines the rendering engine
  62655. * @param camera defines the source camera
  62656. * @param size This parameter can be set to a single number or to an object with the
  62657. * following (optional) properties: precision, width, height. If a single number is passed,
  62658. * it will be used for both width and height. If an object is passed, the screenshot size
  62659. * will be derived from the parameters. The precision property is a multiplier allowing
  62660. * rendering at a higher or lower resolution
  62661. * @param successCallback defines the callback receives a single parameter which contains the
  62662. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62663. * src parameter of an <img> to display it
  62664. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62665. * Check your browser for supported MIME types
  62666. */
  62667. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62668. /**
  62669. * Captures a screenshot of the current rendering
  62670. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62671. * @param engine defines the rendering engine
  62672. * @param camera defines the source camera
  62673. * @param size This parameter can be set to a single number or to an object with the
  62674. * following (optional) properties: precision, width, height. If a single number is passed,
  62675. * it will be used for both width and height. If an object is passed, the screenshot size
  62676. * will be derived from the parameters. The precision property is a multiplier allowing
  62677. * rendering at a higher or lower resolution
  62678. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62679. * Check your browser for supported MIME types
  62680. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62681. * to the src parameter of an <img> to display it
  62682. */
  62683. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62684. /**
  62685. * Generates an image screenshot from the specified camera.
  62686. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62687. * @param engine The engine to use for rendering
  62688. * @param camera The camera to use for rendering
  62689. * @param size This parameter can be set to a single number or to an object with the
  62690. * following (optional) properties: precision, width, height. If a single number is passed,
  62691. * it will be used for both width and height. If an object is passed, the screenshot size
  62692. * will be derived from the parameters. The precision property is a multiplier allowing
  62693. * rendering at a higher or lower resolution
  62694. * @param successCallback The callback receives a single parameter which contains the
  62695. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62696. * src parameter of an <img> to display it
  62697. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62698. * Check your browser for supported MIME types
  62699. * @param samples Texture samples (default: 1)
  62700. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62701. * @param fileName A name for for the downloaded file.
  62702. */
  62703. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62704. /**
  62705. * Generates an image screenshot from the specified camera.
  62706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62707. * @param engine The engine to use for rendering
  62708. * @param camera The camera to use for rendering
  62709. * @param size This parameter can be set to a single number or to an object with the
  62710. * following (optional) properties: precision, width, height. If a single number is passed,
  62711. * it will be used for both width and height. If an object is passed, the screenshot size
  62712. * will be derived from the parameters. The precision property is a multiplier allowing
  62713. * rendering at a higher or lower resolution
  62714. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62715. * Check your browser for supported MIME types
  62716. * @param samples Texture samples (default: 1)
  62717. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62718. * @param fileName A name for for the downloaded file.
  62719. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62720. * to the src parameter of an <img> to display it
  62721. */
  62722. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62723. /**
  62724. * Gets height and width for screenshot size
  62725. * @private
  62726. */
  62727. private static _getScreenshotSize;
  62728. }
  62729. }
  62730. declare module BABYLON {
  62731. /**
  62732. * A cursor which tracks a point on a path
  62733. */
  62734. export class PathCursor {
  62735. private path;
  62736. /**
  62737. * Stores path cursor callbacks for when an onchange event is triggered
  62738. */
  62739. private _onchange;
  62740. /**
  62741. * The value of the path cursor
  62742. */
  62743. value: number;
  62744. /**
  62745. * The animation array of the path cursor
  62746. */
  62747. animations: Animation[];
  62748. /**
  62749. * Initializes the path cursor
  62750. * @param path The path to track
  62751. */
  62752. constructor(path: Path2);
  62753. /**
  62754. * Gets the cursor point on the path
  62755. * @returns A point on the path cursor at the cursor location
  62756. */
  62757. getPoint(): Vector3;
  62758. /**
  62759. * Moves the cursor ahead by the step amount
  62760. * @param step The amount to move the cursor forward
  62761. * @returns This path cursor
  62762. */
  62763. moveAhead(step?: number): PathCursor;
  62764. /**
  62765. * Moves the cursor behind by the step amount
  62766. * @param step The amount to move the cursor back
  62767. * @returns This path cursor
  62768. */
  62769. moveBack(step?: number): PathCursor;
  62770. /**
  62771. * Moves the cursor by the step amount
  62772. * If the step amount is greater than one, an exception is thrown
  62773. * @param step The amount to move the cursor
  62774. * @returns This path cursor
  62775. */
  62776. move(step: number): PathCursor;
  62777. /**
  62778. * Ensures that the value is limited between zero and one
  62779. * @returns This path cursor
  62780. */
  62781. private ensureLimits;
  62782. /**
  62783. * Runs onchange callbacks on change (used by the animation engine)
  62784. * @returns This path cursor
  62785. */
  62786. private raiseOnChange;
  62787. /**
  62788. * Executes a function on change
  62789. * @param f A path cursor onchange callback
  62790. * @returns This path cursor
  62791. */
  62792. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62793. }
  62794. }
  62795. declare module BABYLON {
  62796. /** @hidden */
  62797. export var blurPixelShader: {
  62798. name: string;
  62799. shader: string;
  62800. };
  62801. }
  62802. declare module BABYLON {
  62803. /** @hidden */
  62804. export var pointCloudVertexDeclaration: {
  62805. name: string;
  62806. shader: string;
  62807. };
  62808. }
  62809. // Mixins
  62810. interface Window {
  62811. mozIndexedDB: IDBFactory;
  62812. webkitIndexedDB: IDBFactory;
  62813. msIndexedDB: IDBFactory;
  62814. webkitURL: typeof URL;
  62815. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62816. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62817. WebGLRenderingContext: WebGLRenderingContext;
  62818. MSGesture: MSGesture;
  62819. CANNON: any;
  62820. AudioContext: AudioContext;
  62821. webkitAudioContext: AudioContext;
  62822. PointerEvent: any;
  62823. Math: Math;
  62824. Uint8Array: Uint8ArrayConstructor;
  62825. Float32Array: Float32ArrayConstructor;
  62826. mozURL: typeof URL;
  62827. msURL: typeof URL;
  62828. VRFrameData: any; // WebVR, from specs 1.1
  62829. DracoDecoderModule: any;
  62830. setImmediate(handler: (...args: any[]) => void): number;
  62831. }
  62832. interface HTMLCanvasElement {
  62833. requestPointerLock(): void;
  62834. msRequestPointerLock?(): void;
  62835. mozRequestPointerLock?(): void;
  62836. webkitRequestPointerLock?(): void;
  62837. /** Track wether a record is in progress */
  62838. isRecording: boolean;
  62839. /** Capture Stream method defined by some browsers */
  62840. captureStream(fps?: number): MediaStream;
  62841. }
  62842. interface CanvasRenderingContext2D {
  62843. msImageSmoothingEnabled: boolean;
  62844. }
  62845. interface MouseEvent {
  62846. mozMovementX: number;
  62847. mozMovementY: number;
  62848. webkitMovementX: number;
  62849. webkitMovementY: number;
  62850. msMovementX: number;
  62851. msMovementY: number;
  62852. }
  62853. interface Navigator {
  62854. mozGetVRDevices: (any: any) => any;
  62855. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62856. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62857. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62858. webkitGetGamepads(): Gamepad[];
  62859. msGetGamepads(): Gamepad[];
  62860. webkitGamepads(): Gamepad[];
  62861. }
  62862. interface HTMLVideoElement {
  62863. mozSrcObject: any;
  62864. }
  62865. interface Math {
  62866. fround(x: number): number;
  62867. imul(a: number, b: number): number;
  62868. }
  62869. interface WebGLRenderingContext {
  62870. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62871. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62872. vertexAttribDivisor(index: number, divisor: number): void;
  62873. createVertexArray(): any;
  62874. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62875. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62876. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62877. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62878. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62879. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62880. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62881. // Queries
  62882. createQuery(): WebGLQuery;
  62883. deleteQuery(query: WebGLQuery): void;
  62884. beginQuery(target: number, query: WebGLQuery): void;
  62885. endQuery(target: number): void;
  62886. getQueryParameter(query: WebGLQuery, pname: number): any;
  62887. getQuery(target: number, pname: number): any;
  62888. MAX_SAMPLES: number;
  62889. RGBA8: number;
  62890. READ_FRAMEBUFFER: number;
  62891. DRAW_FRAMEBUFFER: number;
  62892. UNIFORM_BUFFER: number;
  62893. HALF_FLOAT_OES: number;
  62894. RGBA16F: number;
  62895. RGBA32F: number;
  62896. R32F: number;
  62897. RG32F: number;
  62898. RGB32F: number;
  62899. R16F: number;
  62900. RG16F: number;
  62901. RGB16F: number;
  62902. RED: number;
  62903. RG: number;
  62904. R8: number;
  62905. RG8: number;
  62906. UNSIGNED_INT_24_8: number;
  62907. DEPTH24_STENCIL8: number;
  62908. MIN: number;
  62909. MAX: number;
  62910. /* Multiple Render Targets */
  62911. drawBuffers(buffers: number[]): void;
  62912. readBuffer(src: number): void;
  62913. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62914. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62915. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62916. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62917. // Occlusion Query
  62918. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62919. ANY_SAMPLES_PASSED: number;
  62920. QUERY_RESULT_AVAILABLE: number;
  62921. QUERY_RESULT: number;
  62922. }
  62923. interface WebGLProgram {
  62924. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62925. }
  62926. interface EXT_disjoint_timer_query {
  62927. QUERY_COUNTER_BITS_EXT: number;
  62928. TIME_ELAPSED_EXT: number;
  62929. TIMESTAMP_EXT: number;
  62930. GPU_DISJOINT_EXT: number;
  62931. QUERY_RESULT_EXT: number;
  62932. QUERY_RESULT_AVAILABLE_EXT: number;
  62933. queryCounterEXT(query: WebGLQuery, target: number): void;
  62934. createQueryEXT(): WebGLQuery;
  62935. beginQueryEXT(target: number, query: WebGLQuery): void;
  62936. endQueryEXT(target: number): void;
  62937. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62938. deleteQueryEXT(query: WebGLQuery): void;
  62939. }
  62940. interface WebGLUniformLocation {
  62941. _currentState: any;
  62942. }
  62943. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62944. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62945. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62946. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62947. interface WebGLRenderingContext {
  62948. readonly RASTERIZER_DISCARD: number;
  62949. readonly DEPTH_COMPONENT24: number;
  62950. readonly TEXTURE_3D: number;
  62951. readonly TEXTURE_2D_ARRAY: number;
  62952. readonly TEXTURE_COMPARE_FUNC: number;
  62953. readonly TEXTURE_COMPARE_MODE: number;
  62954. readonly COMPARE_REF_TO_TEXTURE: number;
  62955. readonly TEXTURE_WRAP_R: number;
  62956. readonly HALF_FLOAT: number;
  62957. readonly RGB8: number;
  62958. readonly RED_INTEGER: number;
  62959. readonly RG_INTEGER: number;
  62960. readonly RGB_INTEGER: number;
  62961. readonly RGBA_INTEGER: number;
  62962. readonly R8_SNORM: number;
  62963. readonly RG8_SNORM: number;
  62964. readonly RGB8_SNORM: number;
  62965. readonly RGBA8_SNORM: number;
  62966. readonly R8I: number;
  62967. readonly RG8I: number;
  62968. readonly RGB8I: number;
  62969. readonly RGBA8I: number;
  62970. readonly R8UI: number;
  62971. readonly RG8UI: number;
  62972. readonly RGB8UI: number;
  62973. readonly RGBA8UI: number;
  62974. readonly R16I: number;
  62975. readonly RG16I: number;
  62976. readonly RGB16I: number;
  62977. readonly RGBA16I: number;
  62978. readonly R16UI: number;
  62979. readonly RG16UI: number;
  62980. readonly RGB16UI: number;
  62981. readonly RGBA16UI: number;
  62982. readonly R32I: number;
  62983. readonly RG32I: number;
  62984. readonly RGB32I: number;
  62985. readonly RGBA32I: number;
  62986. readonly R32UI: number;
  62987. readonly RG32UI: number;
  62988. readonly RGB32UI: number;
  62989. readonly RGBA32UI: number;
  62990. readonly RGB10_A2UI: number;
  62991. readonly R11F_G11F_B10F: number;
  62992. readonly RGB9_E5: number;
  62993. readonly RGB10_A2: number;
  62994. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62995. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62996. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62997. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62998. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62999. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63000. 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;
  63001. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63002. readonly TRANSFORM_FEEDBACK: number;
  63003. readonly INTERLEAVED_ATTRIBS: number;
  63004. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63005. createTransformFeedback(): WebGLTransformFeedback;
  63006. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63007. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63008. beginTransformFeedback(primitiveMode: number): void;
  63009. endTransformFeedback(): void;
  63010. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63011. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63012. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63013. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63014. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63015. }
  63016. interface ImageBitmap {
  63017. readonly width: number;
  63018. readonly height: number;
  63019. close(): void;
  63020. }
  63021. interface WebGLQuery extends WebGLObject {
  63022. }
  63023. declare var WebGLQuery: {
  63024. prototype: WebGLQuery;
  63025. new(): WebGLQuery;
  63026. };
  63027. interface WebGLSampler extends WebGLObject {
  63028. }
  63029. declare var WebGLSampler: {
  63030. prototype: WebGLSampler;
  63031. new(): WebGLSampler;
  63032. };
  63033. interface WebGLSync extends WebGLObject {
  63034. }
  63035. declare var WebGLSync: {
  63036. prototype: WebGLSync;
  63037. new(): WebGLSync;
  63038. };
  63039. interface WebGLTransformFeedback extends WebGLObject {
  63040. }
  63041. declare var WebGLTransformFeedback: {
  63042. prototype: WebGLTransformFeedback;
  63043. new(): WebGLTransformFeedback;
  63044. };
  63045. interface WebGLVertexArrayObject extends WebGLObject {
  63046. }
  63047. declare var WebGLVertexArrayObject: {
  63048. prototype: WebGLVertexArrayObject;
  63049. new(): WebGLVertexArrayObject;
  63050. };
  63051. // Type definitions for WebVR API
  63052. // Project: https://w3c.github.io/webvr/
  63053. // Definitions by: six a <https://github.com/lostfictions>
  63054. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63055. interface VRDisplay extends EventTarget {
  63056. /**
  63057. * Dictionary of capabilities describing the VRDisplay.
  63058. */
  63059. readonly capabilities: VRDisplayCapabilities;
  63060. /**
  63061. * z-depth defining the far plane of the eye view frustum
  63062. * enables mapping of values in the render target depth
  63063. * attachment to scene coordinates. Initially set to 10000.0.
  63064. */
  63065. depthFar: number;
  63066. /**
  63067. * z-depth defining the near plane of the eye view frustum
  63068. * enables mapping of values in the render target depth
  63069. * attachment to scene coordinates. Initially set to 0.01.
  63070. */
  63071. depthNear: number;
  63072. /**
  63073. * An identifier for this distinct VRDisplay. Used as an
  63074. * association point in the Gamepad API.
  63075. */
  63076. readonly displayId: number;
  63077. /**
  63078. * A display name, a user-readable name identifying it.
  63079. */
  63080. readonly displayName: string;
  63081. readonly isConnected: boolean;
  63082. readonly isPresenting: boolean;
  63083. /**
  63084. * If this VRDisplay supports room-scale experiences, the optional
  63085. * stage attribute contains details on the room-scale parameters.
  63086. */
  63087. readonly stageParameters: VRStageParameters | null;
  63088. /**
  63089. * Passing the value returned by `requestAnimationFrame` to
  63090. * `cancelAnimationFrame` will unregister the callback.
  63091. * @param handle Define the hanle of the request to cancel
  63092. */
  63093. cancelAnimationFrame(handle: number): void;
  63094. /**
  63095. * Stops presenting to the VRDisplay.
  63096. * @returns a promise to know when it stopped
  63097. */
  63098. exitPresent(): Promise<void>;
  63099. /**
  63100. * Return the current VREyeParameters for the given eye.
  63101. * @param whichEye Define the eye we want the parameter for
  63102. * @returns the eye parameters
  63103. */
  63104. getEyeParameters(whichEye: string): VREyeParameters;
  63105. /**
  63106. * Populates the passed VRFrameData with the information required to render
  63107. * the current frame.
  63108. * @param frameData Define the data structure to populate
  63109. * @returns true if ok otherwise false
  63110. */
  63111. getFrameData(frameData: VRFrameData): boolean;
  63112. /**
  63113. * Get the layers currently being presented.
  63114. * @returns the list of VR layers
  63115. */
  63116. getLayers(): VRLayer[];
  63117. /**
  63118. * Return a VRPose containing the future predicted pose of the VRDisplay
  63119. * when the current frame will be presented. The value returned will not
  63120. * change until JavaScript has returned control to the browser.
  63121. *
  63122. * The VRPose will contain the position, orientation, velocity,
  63123. * and acceleration of each of these properties.
  63124. * @returns the pose object
  63125. */
  63126. getPose(): VRPose;
  63127. /**
  63128. * Return the current instantaneous pose of the VRDisplay, with no
  63129. * prediction applied.
  63130. * @returns the current instantaneous pose
  63131. */
  63132. getImmediatePose(): VRPose;
  63133. /**
  63134. * The callback passed to `requestAnimationFrame` will be called
  63135. * any time a new frame should be rendered. When the VRDisplay is
  63136. * presenting the callback will be called at the native refresh
  63137. * rate of the HMD. When not presenting this function acts
  63138. * identically to how window.requestAnimationFrame acts. Content should
  63139. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63140. * asynchronously from other displays and at differing refresh rates.
  63141. * @param callback Define the eaction to run next frame
  63142. * @returns the request handle it
  63143. */
  63144. requestAnimationFrame(callback: FrameRequestCallback): number;
  63145. /**
  63146. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63147. * Repeat calls while already presenting will update the VRLayers being displayed.
  63148. * @param layers Define the list of layer to present
  63149. * @returns a promise to know when the request has been fulfilled
  63150. */
  63151. requestPresent(layers: VRLayer[]): Promise<void>;
  63152. /**
  63153. * Reset the pose for this display, treating its current position and
  63154. * orientation as the "origin/zero" values. VRPose.position,
  63155. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63156. * updated when calling resetPose(). This should be called in only
  63157. * sitting-space experiences.
  63158. */
  63159. resetPose(): void;
  63160. /**
  63161. * The VRLayer provided to the VRDisplay will be captured and presented
  63162. * in the HMD. Calling this function has the same effect on the source
  63163. * canvas as any other operation that uses its source image, and canvases
  63164. * created without preserveDrawingBuffer set to true will be cleared.
  63165. * @param pose Define the pose to submit
  63166. */
  63167. submitFrame(pose?: VRPose): void;
  63168. }
  63169. declare var VRDisplay: {
  63170. prototype: VRDisplay;
  63171. new(): VRDisplay;
  63172. };
  63173. interface VRLayer {
  63174. leftBounds?: number[] | Float32Array | null;
  63175. rightBounds?: number[] | Float32Array | null;
  63176. source?: HTMLCanvasElement | null;
  63177. }
  63178. interface VRDisplayCapabilities {
  63179. readonly canPresent: boolean;
  63180. readonly hasExternalDisplay: boolean;
  63181. readonly hasOrientation: boolean;
  63182. readonly hasPosition: boolean;
  63183. readonly maxLayers: number;
  63184. }
  63185. interface VREyeParameters {
  63186. /** @deprecated */
  63187. readonly fieldOfView: VRFieldOfView;
  63188. readonly offset: Float32Array;
  63189. readonly renderHeight: number;
  63190. readonly renderWidth: number;
  63191. }
  63192. interface VRFieldOfView {
  63193. readonly downDegrees: number;
  63194. readonly leftDegrees: number;
  63195. readonly rightDegrees: number;
  63196. readonly upDegrees: number;
  63197. }
  63198. interface VRFrameData {
  63199. readonly leftProjectionMatrix: Float32Array;
  63200. readonly leftViewMatrix: Float32Array;
  63201. readonly pose: VRPose;
  63202. readonly rightProjectionMatrix: Float32Array;
  63203. readonly rightViewMatrix: Float32Array;
  63204. readonly timestamp: number;
  63205. }
  63206. interface VRPose {
  63207. readonly angularAcceleration: Float32Array | null;
  63208. readonly angularVelocity: Float32Array | null;
  63209. readonly linearAcceleration: Float32Array | null;
  63210. readonly linearVelocity: Float32Array | null;
  63211. readonly orientation: Float32Array | null;
  63212. readonly position: Float32Array | null;
  63213. readonly timestamp: number;
  63214. }
  63215. interface VRStageParameters {
  63216. sittingToStandingTransform?: Float32Array;
  63217. sizeX?: number;
  63218. sizeY?: number;
  63219. }
  63220. interface Navigator {
  63221. getVRDisplays(): Promise<VRDisplay[]>;
  63222. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63223. }
  63224. interface Window {
  63225. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63226. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63227. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63228. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63229. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63230. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63231. }
  63232. interface Gamepad {
  63233. readonly displayId: number;
  63234. }
  63235. type XRSessionMode =
  63236. | "inline"
  63237. | "immersive-vr"
  63238. | "immersive-ar";
  63239. type XRReferenceSpaceType =
  63240. | "viewer"
  63241. | "local"
  63242. | "local-floor"
  63243. | "bounded-floor"
  63244. | "unbounded";
  63245. type XREnvironmentBlendMode =
  63246. | "opaque"
  63247. | "additive"
  63248. | "alpha-blend";
  63249. type XRVisibilityState =
  63250. | "visible"
  63251. | "visible-blurred"
  63252. | "hidden";
  63253. type XRHandedness =
  63254. | "none"
  63255. | "left"
  63256. | "right";
  63257. type XRTargetRayMode =
  63258. | "gaze"
  63259. | "tracked-pointer"
  63260. | "screen";
  63261. type XREye =
  63262. | "none"
  63263. | "left"
  63264. | "right";
  63265. interface XRSpace extends EventTarget {
  63266. }
  63267. interface XRRenderState {
  63268. depthNear?: number;
  63269. depthFar?: number;
  63270. inlineVerticalFieldOfView?: number;
  63271. baseLayer?: XRWebGLLayer;
  63272. }
  63273. interface XRInputSource {
  63274. handedness: XRHandedness;
  63275. targetRayMode: XRTargetRayMode;
  63276. targetRaySpace: XRSpace;
  63277. gripSpace: XRSpace | undefined;
  63278. gamepad: Gamepad | undefined;
  63279. profiles: Array<string>;
  63280. }
  63281. interface XRSession {
  63282. addEventListener: Function;
  63283. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63284. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63285. requestAnimationFrame: Function;
  63286. end(): Promise<void>;
  63287. renderState: XRRenderState;
  63288. inputSources: Array<XRInputSource>;
  63289. }
  63290. interface XRReferenceSpace extends XRSpace {
  63291. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63292. onreset: any;
  63293. }
  63294. interface XRFrame {
  63295. session: XRSession;
  63296. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63297. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63298. }
  63299. interface XRViewerPose extends XRPose {
  63300. views: Array<XRView>;
  63301. }
  63302. interface XRPose {
  63303. transform: XRRigidTransform;
  63304. emulatedPosition: boolean;
  63305. }
  63306. declare var XRWebGLLayer: {
  63307. prototype: XRWebGLLayer;
  63308. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63309. };
  63310. interface XRWebGLLayer {
  63311. framebuffer: WebGLFramebuffer;
  63312. framebufferWidth: number;
  63313. framebufferHeight: number;
  63314. getViewport: Function;
  63315. }
  63316. interface XRRigidTransform {
  63317. position: DOMPointReadOnly;
  63318. orientation: DOMPointReadOnly;
  63319. matrix: Float32Array;
  63320. inverse: XRRigidTransform;
  63321. }
  63322. interface XRView {
  63323. eye: XREye;
  63324. projectionMatrix: Float32Array;
  63325. transform: XRRigidTransform;
  63326. }
  63327. interface XRInputSourceChangeEvent {
  63328. session: XRSession;
  63329. removed: Array<XRInputSource>;
  63330. added: Array<XRInputSource>;
  63331. }
  63332. /**
  63333. * @ignore
  63334. */
  63335. declare module BABYLON.GLTF2.Exporter {
  63336. }
  63337. /**
  63338. * @ignore
  63339. */
  63340. declare module BABYLON.GLTF1 {
  63341. }
  63342. declare module BABYLON.GUI {
  63343. /**
  63344. * Class used to specific a value and its associated unit
  63345. */
  63346. export class ValueAndUnit {
  63347. /** defines the unit to store */
  63348. unit: number;
  63349. /** defines a boolean indicating if the value can be negative */
  63350. negativeValueAllowed: boolean;
  63351. private _value;
  63352. private _originalUnit;
  63353. /**
  63354. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63355. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63356. */
  63357. ignoreAdaptiveScaling: boolean;
  63358. /**
  63359. * Creates a new ValueAndUnit
  63360. * @param value defines the value to store
  63361. * @param unit defines the unit to store
  63362. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63363. */
  63364. constructor(value: number,
  63365. /** defines the unit to store */
  63366. unit?: number,
  63367. /** defines a boolean indicating if the value can be negative */
  63368. negativeValueAllowed?: boolean);
  63369. /** Gets a boolean indicating if the value is a percentage */
  63370. readonly isPercentage: boolean;
  63371. /** Gets a boolean indicating if the value is store as pixel */
  63372. readonly isPixel: boolean;
  63373. /** Gets direct internal value */
  63374. readonly internalValue: number;
  63375. /**
  63376. * Gets value as pixel
  63377. * @param host defines the root host
  63378. * @param refValue defines the reference value for percentages
  63379. * @returns the value as pixel
  63380. */
  63381. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63382. /**
  63383. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63384. * @param value defines the value to store
  63385. * @param unit defines the unit to store
  63386. * @returns the current ValueAndUnit
  63387. */
  63388. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63389. /**
  63390. * Gets the value accordingly to its unit
  63391. * @param host defines the root host
  63392. * @returns the value
  63393. */
  63394. getValue(host: AdvancedDynamicTexture): number;
  63395. /**
  63396. * Gets a string representation of the value
  63397. * @param host defines the root host
  63398. * @param decimals defines an optional number of decimals to display
  63399. * @returns a string
  63400. */
  63401. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63402. /**
  63403. * Store a value parsed from a string
  63404. * @param source defines the source string
  63405. * @returns true if the value was successfully parsed
  63406. */
  63407. fromString(source: string | number): boolean;
  63408. private static _Regex;
  63409. private static _UNITMODE_PERCENTAGE;
  63410. private static _UNITMODE_PIXEL;
  63411. /** UNITMODE_PERCENTAGE */
  63412. static readonly UNITMODE_PERCENTAGE: number;
  63413. /** UNITMODE_PIXEL */
  63414. static readonly UNITMODE_PIXEL: number;
  63415. }
  63416. }
  63417. declare module BABYLON.GUI {
  63418. /**
  63419. * Define a style used by control to automatically setup properties based on a template.
  63420. * Only support font related properties so far
  63421. */
  63422. export class Style implements BABYLON.IDisposable {
  63423. private _fontFamily;
  63424. private _fontStyle;
  63425. private _fontWeight;
  63426. /** @hidden */
  63427. _host: AdvancedDynamicTexture;
  63428. /** @hidden */
  63429. _fontSize: ValueAndUnit;
  63430. /**
  63431. * BABYLON.Observable raised when the style values are changed
  63432. */
  63433. onChangedObservable: BABYLON.Observable<Style>;
  63434. /**
  63435. * Creates a new style object
  63436. * @param host defines the AdvancedDynamicTexture which hosts this style
  63437. */
  63438. constructor(host: AdvancedDynamicTexture);
  63439. /**
  63440. * Gets or sets the font size
  63441. */
  63442. fontSize: string | number;
  63443. /**
  63444. * Gets or sets the font family
  63445. */
  63446. fontFamily: string;
  63447. /**
  63448. * Gets or sets the font style
  63449. */
  63450. fontStyle: string;
  63451. /** Gets or sets font weight */
  63452. fontWeight: string;
  63453. /** Dispose all associated resources */
  63454. dispose(): void;
  63455. }
  63456. }
  63457. declare module BABYLON.GUI {
  63458. /**
  63459. * Class used to transport BABYLON.Vector2 information for pointer events
  63460. */
  63461. export class Vector2WithInfo extends BABYLON.Vector2 {
  63462. /** defines the current mouse button index */
  63463. buttonIndex: number;
  63464. /**
  63465. * Creates a new Vector2WithInfo
  63466. * @param source defines the vector2 data to transport
  63467. * @param buttonIndex defines the current mouse button index
  63468. */
  63469. constructor(source: BABYLON.Vector2,
  63470. /** defines the current mouse button index */
  63471. buttonIndex?: number);
  63472. }
  63473. /** Class used to provide 2D matrix features */
  63474. export class Matrix2D {
  63475. /** Gets the internal array of 6 floats used to store matrix data */
  63476. m: Float32Array;
  63477. /**
  63478. * Creates a new matrix
  63479. * @param m00 defines value for (0, 0)
  63480. * @param m01 defines value for (0, 1)
  63481. * @param m10 defines value for (1, 0)
  63482. * @param m11 defines value for (1, 1)
  63483. * @param m20 defines value for (2, 0)
  63484. * @param m21 defines value for (2, 1)
  63485. */
  63486. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63487. /**
  63488. * Fills the matrix from direct values
  63489. * @param m00 defines value for (0, 0)
  63490. * @param m01 defines value for (0, 1)
  63491. * @param m10 defines value for (1, 0)
  63492. * @param m11 defines value for (1, 1)
  63493. * @param m20 defines value for (2, 0)
  63494. * @param m21 defines value for (2, 1)
  63495. * @returns the current modified matrix
  63496. */
  63497. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63498. /**
  63499. * Gets matrix determinant
  63500. * @returns the determinant
  63501. */
  63502. determinant(): number;
  63503. /**
  63504. * Inverses the matrix and stores it in a target matrix
  63505. * @param result defines the target matrix
  63506. * @returns the current matrix
  63507. */
  63508. invertToRef(result: Matrix2D): Matrix2D;
  63509. /**
  63510. * Multiplies the current matrix with another one
  63511. * @param other defines the second operand
  63512. * @param result defines the target matrix
  63513. * @returns the current matrix
  63514. */
  63515. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63516. /**
  63517. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63518. * @param x defines the x coordinate to transform
  63519. * @param y defines the x coordinate to transform
  63520. * @param result defines the target vector2
  63521. * @returns the current matrix
  63522. */
  63523. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63524. /**
  63525. * Creates an identity matrix
  63526. * @returns a new matrix
  63527. */
  63528. static Identity(): Matrix2D;
  63529. /**
  63530. * Creates a translation matrix and stores it in a target matrix
  63531. * @param x defines the x coordinate of the translation
  63532. * @param y defines the y coordinate of the translation
  63533. * @param result defines the target matrix
  63534. */
  63535. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63536. /**
  63537. * Creates a scaling matrix and stores it in a target matrix
  63538. * @param x defines the x coordinate of the scaling
  63539. * @param y defines the y coordinate of the scaling
  63540. * @param result defines the target matrix
  63541. */
  63542. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63543. /**
  63544. * Creates a rotation matrix and stores it in a target matrix
  63545. * @param angle defines the rotation angle
  63546. * @param result defines the target matrix
  63547. */
  63548. static RotationToRef(angle: number, result: Matrix2D): void;
  63549. private static _TempPreTranslationMatrix;
  63550. private static _TempPostTranslationMatrix;
  63551. private static _TempRotationMatrix;
  63552. private static _TempScalingMatrix;
  63553. private static _TempCompose0;
  63554. private static _TempCompose1;
  63555. private static _TempCompose2;
  63556. /**
  63557. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63558. * @param tx defines the x coordinate of the translation
  63559. * @param ty defines the y coordinate of the translation
  63560. * @param angle defines the rotation angle
  63561. * @param scaleX defines the x coordinate of the scaling
  63562. * @param scaleY defines the y coordinate of the scaling
  63563. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63564. * @param result defines the target matrix
  63565. */
  63566. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63567. }
  63568. }
  63569. declare module BABYLON.GUI {
  63570. /**
  63571. * Class used to store 2D control sizes
  63572. */
  63573. export class Measure {
  63574. /** defines left coordinate */
  63575. left: number;
  63576. /** defines top coordinate */
  63577. top: number;
  63578. /** defines width dimension */
  63579. width: number;
  63580. /** defines height dimension */
  63581. height: number;
  63582. /**
  63583. * Creates a new measure
  63584. * @param left defines left coordinate
  63585. * @param top defines top coordinate
  63586. * @param width defines width dimension
  63587. * @param height defines height dimension
  63588. */
  63589. constructor(
  63590. /** defines left coordinate */
  63591. left: number,
  63592. /** defines top coordinate */
  63593. top: number,
  63594. /** defines width dimension */
  63595. width: number,
  63596. /** defines height dimension */
  63597. height: number);
  63598. /**
  63599. * Copy from another measure
  63600. * @param other defines the other measure to copy from
  63601. */
  63602. copyFrom(other: Measure): void;
  63603. /**
  63604. * Copy from a group of 4 floats
  63605. * @param left defines left coordinate
  63606. * @param top defines top coordinate
  63607. * @param width defines width dimension
  63608. * @param height defines height dimension
  63609. */
  63610. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63611. /**
  63612. * Computes the axis aligned bounding box measure for two given measures
  63613. * @param a Input measure
  63614. * @param b Input measure
  63615. * @param result the resulting bounding measure
  63616. */
  63617. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63618. /**
  63619. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63620. * @param transform the matrix to transform the measure before computing the AABB
  63621. * @param result the resulting AABB
  63622. */
  63623. transformToRef(transform: Matrix2D, result: Measure): void;
  63624. /**
  63625. * Check equality between this measure and another one
  63626. * @param other defines the other measures
  63627. * @returns true if both measures are equals
  63628. */
  63629. isEqualsTo(other: Measure): boolean;
  63630. /**
  63631. * Creates an empty measure
  63632. * @returns a new measure
  63633. */
  63634. static Empty(): Measure;
  63635. }
  63636. }
  63637. declare module BABYLON.GUI {
  63638. /**
  63639. * Interface used to define a control that can receive focus
  63640. */
  63641. export interface IFocusableControl {
  63642. /**
  63643. * Function called when the control receives the focus
  63644. */
  63645. onFocus(): void;
  63646. /**
  63647. * Function called when the control loses the focus
  63648. */
  63649. onBlur(): void;
  63650. /**
  63651. * Function called to let the control handle keyboard events
  63652. * @param evt defines the current keyboard event
  63653. */
  63654. processKeyboard(evt: KeyboardEvent): void;
  63655. /**
  63656. * Function called to get the list of controls that should not steal the focus from this control
  63657. * @returns an array of controls
  63658. */
  63659. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63660. }
  63661. /**
  63662. * Class used to create texture to support 2D GUI elements
  63663. * @see http://doc.babylonjs.com/how_to/gui
  63664. */
  63665. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63666. private _isDirty;
  63667. private _renderObserver;
  63668. private _resizeObserver;
  63669. private _preKeyboardObserver;
  63670. private _pointerMoveObserver;
  63671. private _pointerObserver;
  63672. private _canvasPointerOutObserver;
  63673. private _background;
  63674. /** @hidden */
  63675. _rootContainer: Container;
  63676. /** @hidden */
  63677. _lastPickedControl: Control;
  63678. /** @hidden */
  63679. _lastControlOver: {
  63680. [pointerId: number]: Control;
  63681. };
  63682. /** @hidden */
  63683. _lastControlDown: {
  63684. [pointerId: number]: Control;
  63685. };
  63686. /** @hidden */
  63687. _capturingControl: {
  63688. [pointerId: number]: Control;
  63689. };
  63690. /** @hidden */
  63691. _shouldBlockPointer: boolean;
  63692. /** @hidden */
  63693. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63694. /** @hidden */
  63695. _linkedControls: Control[];
  63696. private _isFullscreen;
  63697. private _fullscreenViewport;
  63698. private _idealWidth;
  63699. private _idealHeight;
  63700. private _useSmallestIdeal;
  63701. private _renderAtIdealSize;
  63702. private _focusedControl;
  63703. private _blockNextFocusCheck;
  63704. private _renderScale;
  63705. private _rootCanvas;
  63706. private _cursorChanged;
  63707. /**
  63708. * Define type to string to ensure compatibility across browsers
  63709. * Safari doesn't support DataTransfer constructor
  63710. */
  63711. private _clipboardData;
  63712. /**
  63713. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63714. */
  63715. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63716. /**
  63717. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63718. */
  63719. onControlPickedObservable: BABYLON.Observable<Control>;
  63720. /**
  63721. * BABYLON.Observable event triggered before layout is evaluated
  63722. */
  63723. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63724. /**
  63725. * BABYLON.Observable event triggered after the layout was evaluated
  63726. */
  63727. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63728. /**
  63729. * BABYLON.Observable event triggered before the texture is rendered
  63730. */
  63731. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63732. /**
  63733. * BABYLON.Observable event triggered after the texture was rendered
  63734. */
  63735. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63736. /**
  63737. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63738. */
  63739. premulAlpha: boolean;
  63740. /**
  63741. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63742. * Useful when you want more antialiasing
  63743. */
  63744. renderScale: number;
  63745. /** Gets or sets the background color */
  63746. background: string;
  63747. /**
  63748. * Gets or sets the ideal width used to design controls.
  63749. * The GUI will then rescale everything accordingly
  63750. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63751. */
  63752. idealWidth: number;
  63753. /**
  63754. * Gets or sets the ideal height used to design controls.
  63755. * The GUI will then rescale everything accordingly
  63756. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63757. */
  63758. idealHeight: number;
  63759. /**
  63760. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63761. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63762. */
  63763. useSmallestIdeal: boolean;
  63764. /**
  63765. * Gets or sets a boolean indicating if adaptive scaling must be used
  63766. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63767. */
  63768. renderAtIdealSize: boolean;
  63769. /**
  63770. * Gets the underlying layer used to render the texture when in fullscreen mode
  63771. */
  63772. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63773. /**
  63774. * Gets the root container control
  63775. */
  63776. readonly rootContainer: Container;
  63777. /**
  63778. * Returns an array containing the root container.
  63779. * This is mostly used to let the Inspector introspects the ADT
  63780. * @returns an array containing the rootContainer
  63781. */
  63782. getChildren(): Array<Container>;
  63783. /**
  63784. * Will return all controls that are inside this texture
  63785. * @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
  63786. * @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
  63787. * @return all child controls
  63788. */
  63789. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63790. /**
  63791. * Gets or sets the current focused control
  63792. */
  63793. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63794. /**
  63795. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63796. */
  63797. isForeground: boolean;
  63798. /**
  63799. * Gets or set information about clipboardData
  63800. */
  63801. clipboardData: string;
  63802. /**
  63803. * Creates a new AdvancedDynamicTexture
  63804. * @param name defines the name of the texture
  63805. * @param width defines the width of the texture
  63806. * @param height defines the height of the texture
  63807. * @param scene defines the hosting scene
  63808. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63809. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63810. */
  63811. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63812. /**
  63813. * Get the current class name of the texture useful for serialization or dynamic coding.
  63814. * @returns "AdvancedDynamicTexture"
  63815. */
  63816. getClassName(): string;
  63817. /**
  63818. * Function used to execute a function on all controls
  63819. * @param func defines the function to execute
  63820. * @param container defines the container where controls belong. If null the root container will be used
  63821. */
  63822. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63823. private _useInvalidateRectOptimization;
  63824. /**
  63825. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63826. */
  63827. useInvalidateRectOptimization: boolean;
  63828. private _invalidatedRectangle;
  63829. /**
  63830. * Invalidates a rectangle area on the gui texture
  63831. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63832. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63833. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63834. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63835. */
  63836. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63837. /**
  63838. * Marks the texture as dirty forcing a complete update
  63839. */
  63840. markAsDirty(): void;
  63841. /**
  63842. * Helper function used to create a new style
  63843. * @returns a new style
  63844. * @see http://doc.babylonjs.com/how_to/gui#styles
  63845. */
  63846. createStyle(): Style;
  63847. /**
  63848. * Adds a new control to the root container
  63849. * @param control defines the control to add
  63850. * @returns the current texture
  63851. */
  63852. addControl(control: Control): AdvancedDynamicTexture;
  63853. /**
  63854. * Removes a control from the root container
  63855. * @param control defines the control to remove
  63856. * @returns the current texture
  63857. */
  63858. removeControl(control: Control): AdvancedDynamicTexture;
  63859. /**
  63860. * Release all resources
  63861. */
  63862. dispose(): void;
  63863. private _onResize;
  63864. /** @hidden */
  63865. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63866. /**
  63867. * Get screen coordinates for a vector3
  63868. * @param position defines the position to project
  63869. * @param worldMatrix defines the world matrix to use
  63870. * @returns the projected position
  63871. */
  63872. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63873. private _checkUpdate;
  63874. private _clearMeasure;
  63875. private _render;
  63876. /** @hidden */
  63877. _changeCursor(cursor: string): void;
  63878. /** @hidden */
  63879. _registerLastControlDown(control: Control, pointerId: number): void;
  63880. private _doPicking;
  63881. /** @hidden */
  63882. _cleanControlAfterRemovalFromList(list: {
  63883. [pointerId: number]: Control;
  63884. }, control: Control): void;
  63885. /** @hidden */
  63886. _cleanControlAfterRemoval(control: Control): void;
  63887. /** Attach to all scene events required to support pointer events */
  63888. attach(): void;
  63889. /** @hidden */
  63890. private onClipboardCopy;
  63891. /** @hidden */
  63892. private onClipboardCut;
  63893. /** @hidden */
  63894. private onClipboardPaste;
  63895. /**
  63896. * Register the clipboard Events onto the canvas
  63897. */
  63898. registerClipboardEvents(): void;
  63899. /**
  63900. * Unregister the clipboard Events from the canvas
  63901. */
  63902. unRegisterClipboardEvents(): void;
  63903. /**
  63904. * Connect the texture to a hosting mesh to enable interactions
  63905. * @param mesh defines the mesh to attach to
  63906. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63907. */
  63908. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63909. /**
  63910. * Move the focus to a specific control
  63911. * @param control defines the control which will receive the focus
  63912. */
  63913. moveFocusToControl(control: IFocusableControl): void;
  63914. private _manageFocus;
  63915. private _attachToOnPointerOut;
  63916. /**
  63917. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63918. * @param mesh defines the mesh which will receive the texture
  63919. * @param width defines the texture width (1024 by default)
  63920. * @param height defines the texture height (1024 by default)
  63921. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63922. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63923. * @returns a new AdvancedDynamicTexture
  63924. */
  63925. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63926. /**
  63927. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63928. * In this mode the texture will rely on a layer for its rendering.
  63929. * This allows it to be treated like any other layer.
  63930. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63931. * LayerMask is set through advancedTexture.layer.layerMask
  63932. * @param name defines name for the texture
  63933. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63934. * @param scene defines the hsoting scene
  63935. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63936. * @returns a new AdvancedDynamicTexture
  63937. */
  63938. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63939. }
  63940. }
  63941. declare module BABYLON.GUI {
  63942. /**
  63943. * Root class used for all 2D controls
  63944. * @see http://doc.babylonjs.com/how_to/gui#controls
  63945. */
  63946. export class Control {
  63947. /** defines the name of the control */
  63948. name?: string | undefined;
  63949. /**
  63950. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63951. */
  63952. static AllowAlphaInheritance: boolean;
  63953. private _alpha;
  63954. private _alphaSet;
  63955. private _zIndex;
  63956. /** @hidden */
  63957. _host: AdvancedDynamicTexture;
  63958. /** Gets or sets the control parent */
  63959. parent: BABYLON.Nullable<Container>;
  63960. /** @hidden */
  63961. _currentMeasure: Measure;
  63962. private _fontFamily;
  63963. private _fontStyle;
  63964. private _fontWeight;
  63965. private _fontSize;
  63966. private _font;
  63967. /** @hidden */
  63968. _width: ValueAndUnit;
  63969. /** @hidden */
  63970. _height: ValueAndUnit;
  63971. /** @hidden */
  63972. protected _fontOffset: {
  63973. ascent: number;
  63974. height: number;
  63975. descent: number;
  63976. };
  63977. private _color;
  63978. private _style;
  63979. private _styleObserver;
  63980. /** @hidden */
  63981. protected _horizontalAlignment: number;
  63982. /** @hidden */
  63983. protected _verticalAlignment: number;
  63984. /** @hidden */
  63985. protected _isDirty: boolean;
  63986. /** @hidden */
  63987. protected _wasDirty: boolean;
  63988. /** @hidden */
  63989. _tempParentMeasure: Measure;
  63990. /** @hidden */
  63991. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63992. /** @hidden */
  63993. protected _cachedParentMeasure: Measure;
  63994. private _paddingLeft;
  63995. private _paddingRight;
  63996. private _paddingTop;
  63997. private _paddingBottom;
  63998. /** @hidden */
  63999. _left: ValueAndUnit;
  64000. /** @hidden */
  64001. _top: ValueAndUnit;
  64002. private _scaleX;
  64003. private _scaleY;
  64004. private _rotation;
  64005. private _transformCenterX;
  64006. private _transformCenterY;
  64007. /** @hidden */
  64008. _transformMatrix: Matrix2D;
  64009. /** @hidden */
  64010. protected _invertTransformMatrix: Matrix2D;
  64011. /** @hidden */
  64012. protected _transformedPosition: BABYLON.Vector2;
  64013. private _isMatrixDirty;
  64014. private _cachedOffsetX;
  64015. private _cachedOffsetY;
  64016. private _isVisible;
  64017. private _isHighlighted;
  64018. /** @hidden */
  64019. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64020. private _fontSet;
  64021. private _dummyVector2;
  64022. private _downCount;
  64023. private _enterCount;
  64024. private _doNotRender;
  64025. private _downPointerIds;
  64026. protected _isEnabled: boolean;
  64027. protected _disabledColor: string;
  64028. /** @hidden */
  64029. protected _rebuildLayout: boolean;
  64030. /** @hidden */
  64031. _isClipped: boolean;
  64032. /** @hidden */
  64033. _tag: any;
  64034. /**
  64035. * 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
  64036. */
  64037. uniqueId: number;
  64038. /**
  64039. * Gets or sets an object used to store user defined information for the node
  64040. */
  64041. metadata: any;
  64042. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64043. isHitTestVisible: boolean;
  64044. /** Gets or sets a boolean indicating if the control can block pointer events */
  64045. isPointerBlocker: boolean;
  64046. /** Gets or sets a boolean indicating if the control can be focusable */
  64047. isFocusInvisible: boolean;
  64048. /**
  64049. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64050. * 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
  64051. */
  64052. clipChildren: boolean;
  64053. /**
  64054. * Gets or sets a boolean indicating that control content must be clipped
  64055. * 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
  64056. */
  64057. clipContent: boolean;
  64058. /**
  64059. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64060. */
  64061. useBitmapCache: boolean;
  64062. private _cacheData;
  64063. private _shadowOffsetX;
  64064. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64065. shadowOffsetX: number;
  64066. private _shadowOffsetY;
  64067. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64068. shadowOffsetY: number;
  64069. private _shadowBlur;
  64070. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64071. shadowBlur: number;
  64072. private _shadowColor;
  64073. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64074. shadowColor: string;
  64075. /** Gets or sets the cursor to use when the control is hovered */
  64076. hoverCursor: string;
  64077. /** @hidden */
  64078. protected _linkOffsetX: ValueAndUnit;
  64079. /** @hidden */
  64080. protected _linkOffsetY: ValueAndUnit;
  64081. /** Gets the control type name */
  64082. readonly typeName: string;
  64083. /**
  64084. * Get the current class name of the control.
  64085. * @returns current class name
  64086. */
  64087. getClassName(): string;
  64088. /**
  64089. * An event triggered when the pointer move over the control.
  64090. */
  64091. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64092. /**
  64093. * An event triggered when the pointer move out of the control.
  64094. */
  64095. onPointerOutObservable: BABYLON.Observable<Control>;
  64096. /**
  64097. * An event triggered when the pointer taps the control
  64098. */
  64099. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64100. /**
  64101. * An event triggered when pointer up
  64102. */
  64103. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64104. /**
  64105. * An event triggered when a control is clicked on
  64106. */
  64107. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64108. /**
  64109. * An event triggered when pointer enters the control
  64110. */
  64111. onPointerEnterObservable: BABYLON.Observable<Control>;
  64112. /**
  64113. * An event triggered when the control is marked as dirty
  64114. */
  64115. onDirtyObservable: BABYLON.Observable<Control>;
  64116. /**
  64117. * An event triggered before drawing the control
  64118. */
  64119. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64120. /**
  64121. * An event triggered after the control was drawn
  64122. */
  64123. onAfterDrawObservable: BABYLON.Observable<Control>;
  64124. /**
  64125. * Get the hosting AdvancedDynamicTexture
  64126. */
  64127. readonly host: AdvancedDynamicTexture;
  64128. /** Gets or set information about font offsets (used to render and align text) */
  64129. fontOffset: {
  64130. ascent: number;
  64131. height: number;
  64132. descent: number;
  64133. };
  64134. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64135. alpha: number;
  64136. /**
  64137. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64138. */
  64139. isHighlighted: boolean;
  64140. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64141. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64142. */
  64143. scaleX: number;
  64144. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64145. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64146. */
  64147. scaleY: number;
  64148. /** Gets or sets the rotation angle (0 by default)
  64149. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64150. */
  64151. rotation: number;
  64152. /** Gets or sets the transformation center on Y axis (0 by default)
  64153. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64154. */
  64155. transformCenterY: number;
  64156. /** Gets or sets the transformation center on X axis (0 by default)
  64157. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64158. */
  64159. transformCenterX: number;
  64160. /**
  64161. * Gets or sets the horizontal alignment
  64162. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64163. */
  64164. horizontalAlignment: number;
  64165. /**
  64166. * Gets or sets the vertical alignment
  64167. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64168. */
  64169. verticalAlignment: number;
  64170. /**
  64171. * Gets or sets control width
  64172. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64173. */
  64174. width: string | number;
  64175. /**
  64176. * Gets or sets the control width in pixel
  64177. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64178. */
  64179. widthInPixels: number;
  64180. /**
  64181. * Gets or sets control height
  64182. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64183. */
  64184. height: string | number;
  64185. /**
  64186. * Gets or sets control height in pixel
  64187. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64188. */
  64189. heightInPixels: number;
  64190. /** Gets or set font family */
  64191. fontFamily: string;
  64192. /** Gets or sets font style */
  64193. fontStyle: string;
  64194. /** Gets or sets font weight */
  64195. fontWeight: string;
  64196. /**
  64197. * Gets or sets style
  64198. * @see http://doc.babylonjs.com/how_to/gui#styles
  64199. */
  64200. style: BABYLON.Nullable<Style>;
  64201. /** @hidden */
  64202. readonly _isFontSizeInPercentage: boolean;
  64203. /** Gets or sets font size in pixels */
  64204. fontSizeInPixels: number;
  64205. /** Gets or sets font size */
  64206. fontSize: string | number;
  64207. /** Gets or sets foreground color */
  64208. color: string;
  64209. /** Gets or sets z index which is used to reorder controls on the z axis */
  64210. zIndex: number;
  64211. /** Gets or sets a boolean indicating if the control can be rendered */
  64212. notRenderable: boolean;
  64213. /** Gets or sets a boolean indicating if the control is visible */
  64214. isVisible: boolean;
  64215. /** Gets a boolean indicating that the control needs to update its rendering */
  64216. readonly isDirty: boolean;
  64217. /**
  64218. * Gets the current linked mesh (or null if none)
  64219. */
  64220. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64221. /**
  64222. * Gets or sets a value indicating the padding to use on the left of the control
  64223. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64224. */
  64225. paddingLeft: string | number;
  64226. /**
  64227. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64228. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64229. */
  64230. paddingLeftInPixels: number;
  64231. /**
  64232. * Gets or sets a value indicating the padding to use on the right of the control
  64233. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64234. */
  64235. paddingRight: string | number;
  64236. /**
  64237. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64238. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64239. */
  64240. paddingRightInPixels: number;
  64241. /**
  64242. * Gets or sets a value indicating the padding to use on the top of the control
  64243. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64244. */
  64245. paddingTop: string | number;
  64246. /**
  64247. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64248. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64249. */
  64250. paddingTopInPixels: number;
  64251. /**
  64252. * Gets or sets a value indicating the padding to use on the bottom of the control
  64253. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64254. */
  64255. paddingBottom: string | number;
  64256. /**
  64257. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64258. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64259. */
  64260. paddingBottomInPixels: number;
  64261. /**
  64262. * Gets or sets a value indicating the left coordinate of the control
  64263. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64264. */
  64265. left: string | number;
  64266. /**
  64267. * Gets or sets a value indicating the left coordinate in pixels of the control
  64268. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64269. */
  64270. leftInPixels: number;
  64271. /**
  64272. * Gets or sets a value indicating the top coordinate of the control
  64273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64274. */
  64275. top: string | number;
  64276. /**
  64277. * Gets or sets a value indicating the top coordinate in pixels of the control
  64278. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64279. */
  64280. topInPixels: number;
  64281. /**
  64282. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64283. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64284. */
  64285. linkOffsetX: string | number;
  64286. /**
  64287. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64288. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64289. */
  64290. linkOffsetXInPixels: number;
  64291. /**
  64292. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64293. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64294. */
  64295. linkOffsetY: string | number;
  64296. /**
  64297. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64298. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64299. */
  64300. linkOffsetYInPixels: number;
  64301. /** Gets the center coordinate on X axis */
  64302. readonly centerX: number;
  64303. /** Gets the center coordinate on Y axis */
  64304. readonly centerY: number;
  64305. /** Gets or sets if control is Enabled*/
  64306. isEnabled: boolean;
  64307. /** Gets or sets background color of control if it's disabled*/
  64308. disabledColor: string;
  64309. /**
  64310. * Creates a new control
  64311. * @param name defines the name of the control
  64312. */
  64313. constructor(
  64314. /** defines the name of the control */
  64315. name?: string | undefined);
  64316. /** @hidden */
  64317. protected _getTypeName(): string;
  64318. /**
  64319. * Gets the first ascendant in the hierarchy of the given type
  64320. * @param className defines the required type
  64321. * @returns the ascendant or null if not found
  64322. */
  64323. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64324. /** @hidden */
  64325. _resetFontCache(): void;
  64326. /**
  64327. * Determines if a container is an ascendant of the current control
  64328. * @param container defines the container to look for
  64329. * @returns true if the container is one of the ascendant of the control
  64330. */
  64331. isAscendant(container: Control): boolean;
  64332. /**
  64333. * Gets coordinates in local control space
  64334. * @param globalCoordinates defines the coordinates to transform
  64335. * @returns the new coordinates in local space
  64336. */
  64337. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64338. /**
  64339. * Gets coordinates in local control space
  64340. * @param globalCoordinates defines the coordinates to transform
  64341. * @param result defines the target vector2 where to store the result
  64342. * @returns the current control
  64343. */
  64344. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64345. /**
  64346. * Gets coordinates in parent local control space
  64347. * @param globalCoordinates defines the coordinates to transform
  64348. * @returns the new coordinates in parent local space
  64349. */
  64350. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64351. /**
  64352. * Move the current control to a vector3 position projected onto the screen.
  64353. * @param position defines the target position
  64354. * @param scene defines the hosting scene
  64355. */
  64356. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64357. /** @hidden */
  64358. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64359. /**
  64360. * Will return all controls that have this control as ascendant
  64361. * @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
  64362. * @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
  64363. * @return all child controls
  64364. */
  64365. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64366. /**
  64367. * Link current control with a target mesh
  64368. * @param mesh defines the mesh to link with
  64369. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64370. */
  64371. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64372. /** @hidden */
  64373. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64374. /** @hidden */
  64375. _offsetLeft(offset: number): void;
  64376. /** @hidden */
  64377. _offsetTop(offset: number): void;
  64378. /** @hidden */
  64379. _markMatrixAsDirty(): void;
  64380. /** @hidden */
  64381. _flagDescendantsAsMatrixDirty(): void;
  64382. /** @hidden */
  64383. _intersectsRect(rect: Measure): boolean;
  64384. /** @hidden */
  64385. protected invalidateRect(): void;
  64386. /** @hidden */
  64387. _markAsDirty(force?: boolean): void;
  64388. /** @hidden */
  64389. _markAllAsDirty(): void;
  64390. /** @hidden */
  64391. _link(host: AdvancedDynamicTexture): void;
  64392. /** @hidden */
  64393. protected _transform(context?: CanvasRenderingContext2D): void;
  64394. /** @hidden */
  64395. _renderHighlight(context: CanvasRenderingContext2D): void;
  64396. /** @hidden */
  64397. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64398. /** @hidden */
  64399. protected _applyStates(context: CanvasRenderingContext2D): void;
  64400. /** @hidden */
  64401. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64402. /** @hidden */
  64403. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64404. protected _evaluateClippingState(parentMeasure: Measure): void;
  64405. /** @hidden */
  64406. _measure(): void;
  64407. /** @hidden */
  64408. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64409. /** @hidden */
  64410. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64411. /** @hidden */
  64412. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64413. /** @hidden */
  64414. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64415. private static _ClipMeasure;
  64416. private _tmpMeasureA;
  64417. private _clip;
  64418. /** @hidden */
  64419. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64420. /** @hidden */
  64421. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64422. /**
  64423. * Tests if a given coordinates belong to the current control
  64424. * @param x defines x coordinate to test
  64425. * @param y defines y coordinate to test
  64426. * @returns true if the coordinates are inside the control
  64427. */
  64428. contains(x: number, y: number): boolean;
  64429. /** @hidden */
  64430. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64431. /** @hidden */
  64432. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64433. /** @hidden */
  64434. _onPointerEnter(target: Control): boolean;
  64435. /** @hidden */
  64436. _onPointerOut(target: Control, force?: boolean): void;
  64437. /** @hidden */
  64438. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64439. /** @hidden */
  64440. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64441. /** @hidden */
  64442. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64443. /** @hidden */
  64444. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64445. private _prepareFont;
  64446. /** Releases associated resources */
  64447. dispose(): void;
  64448. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64449. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64450. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64451. private static _VERTICAL_ALIGNMENT_TOP;
  64452. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64453. private static _VERTICAL_ALIGNMENT_CENTER;
  64454. /** HORIZONTAL_ALIGNMENT_LEFT */
  64455. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64456. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64457. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64458. /** HORIZONTAL_ALIGNMENT_CENTER */
  64459. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64460. /** VERTICAL_ALIGNMENT_TOP */
  64461. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64462. /** VERTICAL_ALIGNMENT_BOTTOM */
  64463. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64464. /** VERTICAL_ALIGNMENT_CENTER */
  64465. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64466. private static _FontHeightSizes;
  64467. /** @hidden */
  64468. static _GetFontOffset(font: string): {
  64469. ascent: number;
  64470. height: number;
  64471. descent: number;
  64472. };
  64473. /**
  64474. * Creates a stack panel that can be used to render headers
  64475. * @param control defines the control to associate with the header
  64476. * @param text defines the text of the header
  64477. * @param size defines the size of the header
  64478. * @param options defines options used to configure the header
  64479. * @returns a new StackPanel
  64480. * @ignore
  64481. * @hidden
  64482. */
  64483. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64484. isHorizontal: boolean;
  64485. controlFirst: boolean;
  64486. }) => any;
  64487. /** @hidden */
  64488. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64489. }
  64490. }
  64491. declare module BABYLON.GUI {
  64492. /**
  64493. * Root class for 2D containers
  64494. * @see http://doc.babylonjs.com/how_to/gui#containers
  64495. */
  64496. export class Container extends Control {
  64497. name?: string | undefined;
  64498. /** @hidden */
  64499. protected _children: Control[];
  64500. /** @hidden */
  64501. protected _measureForChildren: Measure;
  64502. /** @hidden */
  64503. protected _background: string;
  64504. /** @hidden */
  64505. protected _adaptWidthToChildren: boolean;
  64506. /** @hidden */
  64507. protected _adaptHeightToChildren: boolean;
  64508. /**
  64509. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64510. */
  64511. logLayoutCycleErrors: boolean;
  64512. /**
  64513. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64514. */
  64515. maxLayoutCycle: number;
  64516. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64517. adaptHeightToChildren: boolean;
  64518. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64519. adaptWidthToChildren: boolean;
  64520. /** Gets or sets background color */
  64521. background: string;
  64522. /** Gets the list of children */
  64523. readonly children: Control[];
  64524. /**
  64525. * Creates a new Container
  64526. * @param name defines the name of the container
  64527. */
  64528. constructor(name?: string | undefined);
  64529. protected _getTypeName(): string;
  64530. _flagDescendantsAsMatrixDirty(): void;
  64531. /**
  64532. * Gets a child using its name
  64533. * @param name defines the child name to look for
  64534. * @returns the child control if found
  64535. */
  64536. getChildByName(name: string): BABYLON.Nullable<Control>;
  64537. /**
  64538. * Gets a child using its type and its name
  64539. * @param name defines the child name to look for
  64540. * @param type defines the child type to look for
  64541. * @returns the child control if found
  64542. */
  64543. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64544. /**
  64545. * Search for a specific control in children
  64546. * @param control defines the control to look for
  64547. * @returns true if the control is in child list
  64548. */
  64549. containsControl(control: Control): boolean;
  64550. /**
  64551. * Adds a new control to the current container
  64552. * @param control defines the control to add
  64553. * @returns the current container
  64554. */
  64555. addControl(control: BABYLON.Nullable<Control>): Container;
  64556. /**
  64557. * Removes all controls from the current container
  64558. * @returns the current container
  64559. */
  64560. clearControls(): Container;
  64561. /**
  64562. * Removes a control from the current container
  64563. * @param control defines the control to remove
  64564. * @returns the current container
  64565. */
  64566. removeControl(control: Control): Container;
  64567. /** @hidden */
  64568. _reOrderControl(control: Control): void;
  64569. /** @hidden */
  64570. _offsetLeft(offset: number): void;
  64571. /** @hidden */
  64572. _offsetTop(offset: number): void;
  64573. /** @hidden */
  64574. _markAllAsDirty(): void;
  64575. /** @hidden */
  64576. protected _localDraw(context: CanvasRenderingContext2D): void;
  64577. /** @hidden */
  64578. _link(host: AdvancedDynamicTexture): void;
  64579. /** @hidden */
  64580. protected _beforeLayout(): void;
  64581. /** @hidden */
  64582. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64583. /** @hidden */
  64584. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64585. protected _postMeasure(): void;
  64586. /** @hidden */
  64587. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64588. /** @hidden */
  64589. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64590. /** @hidden */
  64591. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64592. /** @hidden */
  64593. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64594. /** Releases associated resources */
  64595. dispose(): void;
  64596. }
  64597. }
  64598. declare module BABYLON.GUI {
  64599. /** Class used to create rectangle container */
  64600. export class Rectangle extends Container {
  64601. name?: string | undefined;
  64602. private _thickness;
  64603. private _cornerRadius;
  64604. /** Gets or sets border thickness */
  64605. thickness: number;
  64606. /** Gets or sets the corner radius angle */
  64607. cornerRadius: number;
  64608. /**
  64609. * Creates a new Rectangle
  64610. * @param name defines the control name
  64611. */
  64612. constructor(name?: string | undefined);
  64613. protected _getTypeName(): string;
  64614. protected _localDraw(context: CanvasRenderingContext2D): void;
  64615. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64616. private _drawRoundedRect;
  64617. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64618. }
  64619. }
  64620. declare module BABYLON.GUI {
  64621. /**
  64622. * Enum that determines the text-wrapping mode to use.
  64623. */
  64624. export enum TextWrapping {
  64625. /**
  64626. * Clip the text when it's larger than Control.width; this is the default mode.
  64627. */
  64628. Clip = 0,
  64629. /**
  64630. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64631. */
  64632. WordWrap = 1,
  64633. /**
  64634. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64635. */
  64636. Ellipsis = 2
  64637. }
  64638. /**
  64639. * Class used to create text block control
  64640. */
  64641. export class TextBlock extends Control {
  64642. /**
  64643. * Defines the name of the control
  64644. */
  64645. name?: string | undefined;
  64646. private _text;
  64647. private _textWrapping;
  64648. private _textHorizontalAlignment;
  64649. private _textVerticalAlignment;
  64650. private _lines;
  64651. private _resizeToFit;
  64652. private _lineSpacing;
  64653. private _outlineWidth;
  64654. private _outlineColor;
  64655. /**
  64656. * An event triggered after the text is changed
  64657. */
  64658. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64659. /**
  64660. * An event triggered after the text was broken up into lines
  64661. */
  64662. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64663. /**
  64664. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64665. */
  64666. readonly lines: any[];
  64667. /**
  64668. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64669. */
  64670. /**
  64671. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64672. */
  64673. resizeToFit: boolean;
  64674. /**
  64675. * Gets or sets a boolean indicating if text must be wrapped
  64676. */
  64677. /**
  64678. * Gets or sets a boolean indicating if text must be wrapped
  64679. */
  64680. textWrapping: TextWrapping | boolean;
  64681. /**
  64682. * Gets or sets text to display
  64683. */
  64684. /**
  64685. * Gets or sets text to display
  64686. */
  64687. text: string;
  64688. /**
  64689. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64690. */
  64691. /**
  64692. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64693. */
  64694. textHorizontalAlignment: number;
  64695. /**
  64696. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64697. */
  64698. /**
  64699. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64700. */
  64701. textVerticalAlignment: number;
  64702. /**
  64703. * Gets or sets line spacing value
  64704. */
  64705. /**
  64706. * Gets or sets line spacing value
  64707. */
  64708. lineSpacing: string | number;
  64709. /**
  64710. * Gets or sets outlineWidth of the text to display
  64711. */
  64712. /**
  64713. * Gets or sets outlineWidth of the text to display
  64714. */
  64715. outlineWidth: number;
  64716. /**
  64717. * Gets or sets outlineColor of the text to display
  64718. */
  64719. /**
  64720. * Gets or sets outlineColor of the text to display
  64721. */
  64722. outlineColor: string;
  64723. /**
  64724. * Creates a new TextBlock object
  64725. * @param name defines the name of the control
  64726. * @param text defines the text to display (emptry string by default)
  64727. */
  64728. constructor(
  64729. /**
  64730. * Defines the name of the control
  64731. */
  64732. name?: string | undefined, text?: string);
  64733. protected _getTypeName(): string;
  64734. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64735. private _drawText;
  64736. /** @hidden */
  64737. _draw(context: CanvasRenderingContext2D): void;
  64738. protected _applyStates(context: CanvasRenderingContext2D): void;
  64739. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64740. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64741. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64742. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64743. protected _renderLines(context: CanvasRenderingContext2D): void;
  64744. /**
  64745. * Given a width constraint applied on the text block, find the expected height
  64746. * @returns expected height
  64747. */
  64748. computeExpectedHeight(): number;
  64749. dispose(): void;
  64750. }
  64751. }
  64752. declare module BABYLON.GUI {
  64753. /**
  64754. * Class used to create 2D images
  64755. */
  64756. export class Image extends Control {
  64757. name?: string | undefined;
  64758. private static _WorkingCanvas;
  64759. private _domImage;
  64760. private _imageWidth;
  64761. private _imageHeight;
  64762. private _loaded;
  64763. private _stretch;
  64764. private _source;
  64765. private _autoScale;
  64766. private _sourceLeft;
  64767. private _sourceTop;
  64768. private _sourceWidth;
  64769. private _sourceHeight;
  64770. private _cellWidth;
  64771. private _cellHeight;
  64772. private _cellId;
  64773. private _populateNinePatchSlicesFromImage;
  64774. private _sliceLeft;
  64775. private _sliceRight;
  64776. private _sliceTop;
  64777. private _sliceBottom;
  64778. private _detectPointerOnOpaqueOnly;
  64779. /**
  64780. * BABYLON.Observable notified when the content is loaded
  64781. */
  64782. onImageLoadedObservable: BABYLON.Observable<Image>;
  64783. /**
  64784. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64785. */
  64786. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64787. /**
  64788. * Gets a boolean indicating that the content is loaded
  64789. */
  64790. readonly isLoaded: boolean;
  64791. /**
  64792. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64793. */
  64794. populateNinePatchSlicesFromImage: boolean;
  64795. /**
  64796. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64797. * Beware using this as this will comsume more memory as the image has to be stored twice
  64798. */
  64799. detectPointerOnOpaqueOnly: boolean;
  64800. /**
  64801. * Gets or sets the left value for slicing (9-patch)
  64802. */
  64803. sliceLeft: number;
  64804. /**
  64805. * Gets or sets the right value for slicing (9-patch)
  64806. */
  64807. sliceRight: number;
  64808. /**
  64809. * Gets or sets the top value for slicing (9-patch)
  64810. */
  64811. sliceTop: number;
  64812. /**
  64813. * Gets or sets the bottom value for slicing (9-patch)
  64814. */
  64815. sliceBottom: number;
  64816. /**
  64817. * Gets or sets the left coordinate in the source image
  64818. */
  64819. sourceLeft: number;
  64820. /**
  64821. * Gets or sets the top coordinate in the source image
  64822. */
  64823. sourceTop: number;
  64824. /**
  64825. * Gets or sets the width to capture in the source image
  64826. */
  64827. sourceWidth: number;
  64828. /**
  64829. * Gets or sets the height to capture in the source image
  64830. */
  64831. sourceHeight: number;
  64832. /**
  64833. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64834. * @see http://doc.babylonjs.com/how_to/gui#image
  64835. */
  64836. autoScale: boolean;
  64837. /** Gets or sets the streching mode used by the image */
  64838. stretch: number;
  64839. /**
  64840. * Gets or sets the internal DOM image used to render the control
  64841. */
  64842. domImage: HTMLImageElement;
  64843. private _onImageLoaded;
  64844. private _extractNinePatchSliceDataFromImage;
  64845. /**
  64846. * Gets or sets image source url
  64847. */
  64848. source: BABYLON.Nullable<string>;
  64849. /**
  64850. * Checks for svg document with icon id present
  64851. */
  64852. private _svgCheck;
  64853. /**
  64854. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64855. * given external svg file and icon id
  64856. */
  64857. private _getSVGAttribs;
  64858. /**
  64859. * Gets or sets the cell width to use when animation sheet is enabled
  64860. * @see http://doc.babylonjs.com/how_to/gui#image
  64861. */
  64862. cellWidth: number;
  64863. /**
  64864. * Gets or sets the cell height to use when animation sheet is enabled
  64865. * @see http://doc.babylonjs.com/how_to/gui#image
  64866. */
  64867. cellHeight: number;
  64868. /**
  64869. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64870. * @see http://doc.babylonjs.com/how_to/gui#image
  64871. */
  64872. cellId: number;
  64873. /**
  64874. * Creates a new Image
  64875. * @param name defines the control name
  64876. * @param url defines the image url
  64877. */
  64878. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64879. /**
  64880. * Tests if a given coordinates belong to the current control
  64881. * @param x defines x coordinate to test
  64882. * @param y defines y coordinate to test
  64883. * @returns true if the coordinates are inside the control
  64884. */
  64885. contains(x: number, y: number): boolean;
  64886. protected _getTypeName(): string;
  64887. /** Force the control to synchronize with its content */
  64888. synchronizeSizeWithContent(): void;
  64889. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64890. private _prepareWorkingCanvasForOpaqueDetection;
  64891. private _drawImage;
  64892. _draw(context: CanvasRenderingContext2D): void;
  64893. private _renderCornerPatch;
  64894. private _renderNinePatch;
  64895. dispose(): void;
  64896. /** STRETCH_NONE */
  64897. static readonly STRETCH_NONE: number;
  64898. /** STRETCH_FILL */
  64899. static readonly STRETCH_FILL: number;
  64900. /** STRETCH_UNIFORM */
  64901. static readonly STRETCH_UNIFORM: number;
  64902. /** STRETCH_EXTEND */
  64903. static readonly STRETCH_EXTEND: number;
  64904. /** NINE_PATCH */
  64905. static readonly STRETCH_NINE_PATCH: number;
  64906. }
  64907. }
  64908. declare module BABYLON.GUI {
  64909. /**
  64910. * Class used to create 2D buttons
  64911. */
  64912. export class Button extends Rectangle {
  64913. name?: string | undefined;
  64914. /**
  64915. * Function called to generate a pointer enter animation
  64916. */
  64917. pointerEnterAnimation: () => void;
  64918. /**
  64919. * Function called to generate a pointer out animation
  64920. */
  64921. pointerOutAnimation: () => void;
  64922. /**
  64923. * Function called to generate a pointer down animation
  64924. */
  64925. pointerDownAnimation: () => void;
  64926. /**
  64927. * Function called to generate a pointer up animation
  64928. */
  64929. pointerUpAnimation: () => void;
  64930. /**
  64931. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64932. */
  64933. delegatePickingToChildren: boolean;
  64934. private _image;
  64935. /**
  64936. * Returns the image part of the button (if any)
  64937. */
  64938. readonly image: BABYLON.Nullable<Image>;
  64939. private _textBlock;
  64940. /**
  64941. * Returns the image part of the button (if any)
  64942. */
  64943. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64944. /**
  64945. * Creates a new Button
  64946. * @param name defines the name of the button
  64947. */
  64948. constructor(name?: string | undefined);
  64949. protected _getTypeName(): string;
  64950. /** @hidden */
  64951. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64952. /** @hidden */
  64953. _onPointerEnter(target: Control): boolean;
  64954. /** @hidden */
  64955. _onPointerOut(target: Control, force?: boolean): void;
  64956. /** @hidden */
  64957. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64958. /** @hidden */
  64959. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64960. /**
  64961. * Creates a new button made with an image and a text
  64962. * @param name defines the name of the button
  64963. * @param text defines the text of the button
  64964. * @param imageUrl defines the url of the image
  64965. * @returns a new Button
  64966. */
  64967. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64968. /**
  64969. * Creates a new button made with an image
  64970. * @param name defines the name of the button
  64971. * @param imageUrl defines the url of the image
  64972. * @returns a new Button
  64973. */
  64974. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64975. /**
  64976. * Creates a new button made with a text
  64977. * @param name defines the name of the button
  64978. * @param text defines the text of the button
  64979. * @returns a new Button
  64980. */
  64981. static CreateSimpleButton(name: string, text: string): Button;
  64982. /**
  64983. * Creates a new button made with an image and a centered text
  64984. * @param name defines the name of the button
  64985. * @param text defines the text of the button
  64986. * @param imageUrl defines the url of the image
  64987. * @returns a new Button
  64988. */
  64989. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64990. }
  64991. }
  64992. declare module BABYLON.GUI {
  64993. /**
  64994. * Class used to create a 2D stack panel container
  64995. */
  64996. export class StackPanel extends Container {
  64997. name?: string | undefined;
  64998. private _isVertical;
  64999. private _manualWidth;
  65000. private _manualHeight;
  65001. private _doNotTrackManualChanges;
  65002. /**
  65003. * Gets or sets a boolean indicating that layou warnings should be ignored
  65004. */
  65005. ignoreLayoutWarnings: boolean;
  65006. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65007. isVertical: boolean;
  65008. /**
  65009. * Gets or sets panel width.
  65010. * This value should not be set when in horizontal mode as it will be computed automatically
  65011. */
  65012. width: string | number;
  65013. /**
  65014. * Gets or sets panel height.
  65015. * This value should not be set when in vertical mode as it will be computed automatically
  65016. */
  65017. height: string | number;
  65018. /**
  65019. * Creates a new StackPanel
  65020. * @param name defines control name
  65021. */
  65022. constructor(name?: string | undefined);
  65023. protected _getTypeName(): string;
  65024. /** @hidden */
  65025. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65026. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65027. protected _postMeasure(): void;
  65028. }
  65029. }
  65030. declare module BABYLON.GUI {
  65031. /**
  65032. * Class used to represent a 2D checkbox
  65033. */
  65034. export class Checkbox extends Control {
  65035. name?: string | undefined;
  65036. private _isChecked;
  65037. private _background;
  65038. private _checkSizeRatio;
  65039. private _thickness;
  65040. /** Gets or sets border thickness */
  65041. thickness: number;
  65042. /**
  65043. * BABYLON.Observable raised when isChecked property changes
  65044. */
  65045. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65046. /** Gets or sets a value indicating the ratio between overall size and check size */
  65047. checkSizeRatio: number;
  65048. /** Gets or sets background color */
  65049. background: string;
  65050. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65051. isChecked: boolean;
  65052. /**
  65053. * Creates a new CheckBox
  65054. * @param name defines the control name
  65055. */
  65056. constructor(name?: string | undefined);
  65057. protected _getTypeName(): string;
  65058. /** @hidden */
  65059. _draw(context: CanvasRenderingContext2D): void;
  65060. /** @hidden */
  65061. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65062. /**
  65063. * Utility function to easily create a checkbox with a header
  65064. * @param title defines the label to use for the header
  65065. * @param onValueChanged defines the callback to call when value changes
  65066. * @returns a StackPanel containing the checkbox and a textBlock
  65067. */
  65068. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65069. }
  65070. }
  65071. declare module BABYLON.GUI {
  65072. /**
  65073. * Class used to store key control properties
  65074. */
  65075. export class KeyPropertySet {
  65076. /** Width */
  65077. width?: string;
  65078. /** Height */
  65079. height?: string;
  65080. /** Left padding */
  65081. paddingLeft?: string;
  65082. /** Right padding */
  65083. paddingRight?: string;
  65084. /** Top padding */
  65085. paddingTop?: string;
  65086. /** Bottom padding */
  65087. paddingBottom?: string;
  65088. /** Foreground color */
  65089. color?: string;
  65090. /** Background color */
  65091. background?: string;
  65092. }
  65093. /**
  65094. * Class used to create virtual keyboard
  65095. */
  65096. export class VirtualKeyboard extends StackPanel {
  65097. /** BABYLON.Observable raised when a key is pressed */
  65098. onKeyPressObservable: BABYLON.Observable<string>;
  65099. /** Gets or sets default key button width */
  65100. defaultButtonWidth: string;
  65101. /** Gets or sets default key button height */
  65102. defaultButtonHeight: string;
  65103. /** Gets or sets default key button left padding */
  65104. defaultButtonPaddingLeft: string;
  65105. /** Gets or sets default key button right padding */
  65106. defaultButtonPaddingRight: string;
  65107. /** Gets or sets default key button top padding */
  65108. defaultButtonPaddingTop: string;
  65109. /** Gets or sets default key button bottom padding */
  65110. defaultButtonPaddingBottom: string;
  65111. /** Gets or sets default key button foreground color */
  65112. defaultButtonColor: string;
  65113. /** Gets or sets default key button background color */
  65114. defaultButtonBackground: string;
  65115. /** Gets or sets shift button foreground color */
  65116. shiftButtonColor: string;
  65117. /** Gets or sets shift button thickness*/
  65118. selectedShiftThickness: number;
  65119. /** Gets shift key state */
  65120. shiftState: number;
  65121. protected _getTypeName(): string;
  65122. private _createKey;
  65123. /**
  65124. * Adds a new row of keys
  65125. * @param keys defines the list of keys to add
  65126. * @param propertySets defines the associated property sets
  65127. */
  65128. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65129. /**
  65130. * Set the shift key to a specific state
  65131. * @param shiftState defines the new shift state
  65132. */
  65133. applyShiftState(shiftState: number): void;
  65134. private _currentlyConnectedInputText;
  65135. private _connectedInputTexts;
  65136. private _onKeyPressObserver;
  65137. /** Gets the input text control currently attached to the keyboard */
  65138. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65139. /**
  65140. * Connects the keyboard with an input text control
  65141. *
  65142. * @param input defines the target control
  65143. */
  65144. connect(input: InputText): void;
  65145. /**
  65146. * Disconnects the keyboard from connected InputText controls
  65147. *
  65148. * @param input optionally defines a target control, otherwise all are disconnected
  65149. */
  65150. disconnect(input?: InputText): void;
  65151. private _removeConnectedInputObservables;
  65152. /**
  65153. * Release all resources
  65154. */
  65155. dispose(): void;
  65156. /**
  65157. * Creates a new keyboard using a default layout
  65158. *
  65159. * @param name defines control name
  65160. * @returns a new VirtualKeyboard
  65161. */
  65162. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65163. }
  65164. }
  65165. declare module BABYLON.GUI {
  65166. /**
  65167. * Class used to create input text control
  65168. */
  65169. export class InputText extends Control implements IFocusableControl {
  65170. name?: string | undefined;
  65171. private _text;
  65172. private _placeholderText;
  65173. private _background;
  65174. private _focusedBackground;
  65175. private _focusedColor;
  65176. private _placeholderColor;
  65177. private _thickness;
  65178. private _margin;
  65179. private _autoStretchWidth;
  65180. private _maxWidth;
  65181. private _isFocused;
  65182. private _blinkTimeout;
  65183. private _blinkIsEven;
  65184. private _cursorOffset;
  65185. private _scrollLeft;
  65186. private _textWidth;
  65187. private _clickedCoordinate;
  65188. private _deadKey;
  65189. private _addKey;
  65190. private _currentKey;
  65191. private _isTextHighlightOn;
  65192. private _textHighlightColor;
  65193. private _highligherOpacity;
  65194. private _highlightedText;
  65195. private _startHighlightIndex;
  65196. private _endHighlightIndex;
  65197. private _cursorIndex;
  65198. private _onFocusSelectAll;
  65199. private _isPointerDown;
  65200. private _onClipboardObserver;
  65201. private _onPointerDblTapObserver;
  65202. /** @hidden */
  65203. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65204. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65205. promptMessage: string;
  65206. /** Force disable prompt on mobile device */
  65207. disableMobilePrompt: boolean;
  65208. /** BABYLON.Observable raised when the text changes */
  65209. onTextChangedObservable: BABYLON.Observable<InputText>;
  65210. /** BABYLON.Observable raised just before an entered character is to be added */
  65211. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65212. /** BABYLON.Observable raised when the control gets the focus */
  65213. onFocusObservable: BABYLON.Observable<InputText>;
  65214. /** BABYLON.Observable raised when the control loses the focus */
  65215. onBlurObservable: BABYLON.Observable<InputText>;
  65216. /**Observable raised when the text is highlighted */
  65217. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65218. /**Observable raised when copy event is triggered */
  65219. onTextCopyObservable: BABYLON.Observable<InputText>;
  65220. /** BABYLON.Observable raised when cut event is triggered */
  65221. onTextCutObservable: BABYLON.Observable<InputText>;
  65222. /** BABYLON.Observable raised when paste event is triggered */
  65223. onTextPasteObservable: BABYLON.Observable<InputText>;
  65224. /** BABYLON.Observable raised when a key event was processed */
  65225. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65226. /** Gets or sets the maximum width allowed by the control */
  65227. maxWidth: string | number;
  65228. /** Gets the maximum width allowed by the control in pixels */
  65229. readonly maxWidthInPixels: number;
  65230. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65231. highligherOpacity: number;
  65232. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65233. onFocusSelectAll: boolean;
  65234. /** Gets or sets the text hightlight color */
  65235. textHighlightColor: string;
  65236. /** Gets or sets control margin */
  65237. margin: string;
  65238. /** Gets control margin in pixels */
  65239. readonly marginInPixels: number;
  65240. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65241. autoStretchWidth: boolean;
  65242. /** Gets or sets border thickness */
  65243. thickness: number;
  65244. /** Gets or sets the background color when focused */
  65245. focusedBackground: string;
  65246. /** Gets or sets the background color when focused */
  65247. focusedColor: string;
  65248. /** Gets or sets the background color */
  65249. background: string;
  65250. /** Gets or sets the placeholder color */
  65251. placeholderColor: string;
  65252. /** Gets or sets the text displayed when the control is empty */
  65253. placeholderText: string;
  65254. /** Gets or sets the dead key flag */
  65255. deadKey: boolean;
  65256. /** Gets or sets the highlight text */
  65257. highlightedText: string;
  65258. /** Gets or sets if the current key should be added */
  65259. addKey: boolean;
  65260. /** Gets or sets the value of the current key being entered */
  65261. currentKey: string;
  65262. /** Gets or sets the text displayed in the control */
  65263. text: string;
  65264. /** Gets or sets control width */
  65265. width: string | number;
  65266. /**
  65267. * Creates a new InputText
  65268. * @param name defines the control name
  65269. * @param text defines the text of the control
  65270. */
  65271. constructor(name?: string | undefined, text?: string);
  65272. /** @hidden */
  65273. onBlur(): void;
  65274. /** @hidden */
  65275. onFocus(): void;
  65276. protected _getTypeName(): string;
  65277. /**
  65278. * Function called to get the list of controls that should not steal the focus from this control
  65279. * @returns an array of controls
  65280. */
  65281. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65282. /** @hidden */
  65283. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65284. /** @hidden */
  65285. private _updateValueFromCursorIndex;
  65286. /** @hidden */
  65287. private _processDblClick;
  65288. /** @hidden */
  65289. private _selectAllText;
  65290. /**
  65291. * Handles the keyboard event
  65292. * @param evt Defines the KeyboardEvent
  65293. */
  65294. processKeyboard(evt: KeyboardEvent): void;
  65295. /** @hidden */
  65296. private _onCopyText;
  65297. /** @hidden */
  65298. private _onCutText;
  65299. /** @hidden */
  65300. private _onPasteText;
  65301. _draw(context: CanvasRenderingContext2D): void;
  65302. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65303. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65304. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65305. protected _beforeRenderText(text: string): string;
  65306. dispose(): void;
  65307. }
  65308. }
  65309. declare module BABYLON.GUI {
  65310. /**
  65311. * Class used to create a 2D grid container
  65312. */
  65313. export class Grid extends Container {
  65314. name?: string | undefined;
  65315. private _rowDefinitions;
  65316. private _columnDefinitions;
  65317. private _cells;
  65318. private _childControls;
  65319. /**
  65320. * Gets the number of columns
  65321. */
  65322. readonly columnCount: number;
  65323. /**
  65324. * Gets the number of rows
  65325. */
  65326. readonly rowCount: number;
  65327. /** Gets the list of children */
  65328. readonly children: Control[];
  65329. /** Gets the list of cells (e.g. the containers) */
  65330. readonly cells: {
  65331. [key: string]: Container;
  65332. };
  65333. /**
  65334. * Gets the definition of a specific row
  65335. * @param index defines the index of the row
  65336. * @returns the row definition
  65337. */
  65338. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65339. /**
  65340. * Gets the definition of a specific column
  65341. * @param index defines the index of the column
  65342. * @returns the column definition
  65343. */
  65344. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65345. /**
  65346. * Adds a new row to the grid
  65347. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65348. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65349. * @returns the current grid
  65350. */
  65351. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65352. /**
  65353. * Adds a new column to the grid
  65354. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65355. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65356. * @returns the current grid
  65357. */
  65358. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65359. /**
  65360. * Update a row definition
  65361. * @param index defines the index of the row to update
  65362. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65363. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65364. * @returns the current grid
  65365. */
  65366. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65367. /**
  65368. * Update a column definition
  65369. * @param index defines the index of the column to update
  65370. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65371. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65372. * @returns the current grid
  65373. */
  65374. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65375. /**
  65376. * Gets the list of children stored in a specific cell
  65377. * @param row defines the row to check
  65378. * @param column defines the column to check
  65379. * @returns the list of controls
  65380. */
  65381. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65382. /**
  65383. * Gets a string representing the child cell info (row x column)
  65384. * @param child defines the control to get info from
  65385. * @returns a string containing the child cell info (row x column)
  65386. */
  65387. getChildCellInfo(child: Control): string;
  65388. private _removeCell;
  65389. private _offsetCell;
  65390. /**
  65391. * Remove a column definition at specified index
  65392. * @param index defines the index of the column to remove
  65393. * @returns the current grid
  65394. */
  65395. removeColumnDefinition(index: number): Grid;
  65396. /**
  65397. * Remove a row definition at specified index
  65398. * @param index defines the index of the row to remove
  65399. * @returns the current grid
  65400. */
  65401. removeRowDefinition(index: number): Grid;
  65402. /**
  65403. * Adds a new control to the current grid
  65404. * @param control defines the control to add
  65405. * @param row defines the row where to add the control (0 by default)
  65406. * @param column defines the column where to add the control (0 by default)
  65407. * @returns the current grid
  65408. */
  65409. addControl(control: Control, row?: number, column?: number): Grid;
  65410. /**
  65411. * Removes a control from the current container
  65412. * @param control defines the control to remove
  65413. * @returns the current container
  65414. */
  65415. removeControl(control: Control): Container;
  65416. /**
  65417. * Creates a new Grid
  65418. * @param name defines control name
  65419. */
  65420. constructor(name?: string | undefined);
  65421. protected _getTypeName(): string;
  65422. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65423. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65424. _flagDescendantsAsMatrixDirty(): void;
  65425. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65426. /** Releases associated resources */
  65427. dispose(): void;
  65428. }
  65429. }
  65430. declare module BABYLON.GUI {
  65431. /** Class used to create color pickers */
  65432. export class ColorPicker extends Control {
  65433. name?: string | undefined;
  65434. private static _Epsilon;
  65435. private _colorWheelCanvas;
  65436. private _value;
  65437. private _tmpColor;
  65438. private _pointerStartedOnSquare;
  65439. private _pointerStartedOnWheel;
  65440. private _squareLeft;
  65441. private _squareTop;
  65442. private _squareSize;
  65443. private _h;
  65444. private _s;
  65445. private _v;
  65446. private _lastPointerDownID;
  65447. /**
  65448. * BABYLON.Observable raised when the value changes
  65449. */
  65450. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65451. /** Gets or sets the color of the color picker */
  65452. value: BABYLON.Color3;
  65453. /**
  65454. * Gets or sets control width
  65455. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65456. */
  65457. width: string | number;
  65458. /**
  65459. * Gets or sets control height
  65460. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65461. */
  65462. /** Gets or sets control height */
  65463. height: string | number;
  65464. /** Gets or sets control size */
  65465. size: string | number;
  65466. /**
  65467. * Creates a new ColorPicker
  65468. * @param name defines the control name
  65469. */
  65470. constructor(name?: string | undefined);
  65471. protected _getTypeName(): string;
  65472. /** @hidden */
  65473. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65474. private _updateSquareProps;
  65475. private _drawGradientSquare;
  65476. private _drawCircle;
  65477. private _createColorWheelCanvas;
  65478. /** @hidden */
  65479. _draw(context: CanvasRenderingContext2D): void;
  65480. private _pointerIsDown;
  65481. private _updateValueFromPointer;
  65482. private _isPointOnSquare;
  65483. private _isPointOnWheel;
  65484. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65485. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65486. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65487. /**
  65488. * This function expands the color picker by creating a color picker dialog with manual
  65489. * color value input and the ability to save colors into an array to be used later in
  65490. * subsequent launches of the dialogue.
  65491. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65492. * @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.
  65493. * @returns picked color as a hex string and the saved colors array as hex strings.
  65494. */
  65495. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65496. pickerWidth?: string;
  65497. pickerHeight?: string;
  65498. headerHeight?: string;
  65499. lastColor?: string;
  65500. swatchLimit?: number;
  65501. numSwatchesPerLine?: number;
  65502. savedColors?: Array<string>;
  65503. }): Promise<{
  65504. savedColors?: string[];
  65505. pickedColor: string;
  65506. }>;
  65507. }
  65508. }
  65509. declare module BABYLON.GUI {
  65510. /** Class used to create 2D ellipse containers */
  65511. export class Ellipse extends Container {
  65512. name?: string | undefined;
  65513. private _thickness;
  65514. /** Gets or sets border thickness */
  65515. thickness: number;
  65516. /**
  65517. * Creates a new Ellipse
  65518. * @param name defines the control name
  65519. */
  65520. constructor(name?: string | undefined);
  65521. protected _getTypeName(): string;
  65522. protected _localDraw(context: CanvasRenderingContext2D): void;
  65523. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65524. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65525. }
  65526. }
  65527. declare module BABYLON.GUI {
  65528. /**
  65529. * Class used to create a password control
  65530. */
  65531. export class InputPassword extends InputText {
  65532. protected _beforeRenderText(text: string): string;
  65533. }
  65534. }
  65535. declare module BABYLON.GUI {
  65536. /** Class used to render 2D lines */
  65537. export class Line extends Control {
  65538. name?: string | undefined;
  65539. private _lineWidth;
  65540. private _x1;
  65541. private _y1;
  65542. private _x2;
  65543. private _y2;
  65544. private _dash;
  65545. private _connectedControl;
  65546. private _connectedControlDirtyObserver;
  65547. /** Gets or sets the dash pattern */
  65548. dash: Array<number>;
  65549. /** Gets or sets the control connected with the line end */
  65550. connectedControl: Control;
  65551. /** Gets or sets start coordinates on X axis */
  65552. x1: string | number;
  65553. /** Gets or sets start coordinates on Y axis */
  65554. y1: string | number;
  65555. /** Gets or sets end coordinates on X axis */
  65556. x2: string | number;
  65557. /** Gets or sets end coordinates on Y axis */
  65558. y2: string | number;
  65559. /** Gets or sets line width */
  65560. lineWidth: number;
  65561. /** Gets or sets horizontal alignment */
  65562. horizontalAlignment: number;
  65563. /** Gets or sets vertical alignment */
  65564. verticalAlignment: number;
  65565. private readonly _effectiveX2;
  65566. private readonly _effectiveY2;
  65567. /**
  65568. * Creates a new Line
  65569. * @param name defines the control name
  65570. */
  65571. constructor(name?: string | undefined);
  65572. protected _getTypeName(): string;
  65573. _draw(context: CanvasRenderingContext2D): void;
  65574. _measure(): void;
  65575. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65576. /**
  65577. * Move one end of the line given 3D cartesian coordinates.
  65578. * @param position Targeted world position
  65579. * @param scene BABYLON.Scene
  65580. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65581. */
  65582. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65583. /**
  65584. * Move one end of the line to a position in screen absolute space.
  65585. * @param projectedPosition Position in screen absolute space (X, Y)
  65586. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65587. */
  65588. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65589. }
  65590. }
  65591. declare module BABYLON.GUI {
  65592. /**
  65593. * Class used to store a point for a MultiLine object.
  65594. * The point can be pure 2D coordinates, a mesh or a control
  65595. */
  65596. export class MultiLinePoint {
  65597. private _multiLine;
  65598. private _x;
  65599. private _y;
  65600. private _control;
  65601. private _mesh;
  65602. private _controlObserver;
  65603. private _meshObserver;
  65604. /** @hidden */
  65605. _point: BABYLON.Vector2;
  65606. /**
  65607. * Creates a new MultiLinePoint
  65608. * @param multiLine defines the source MultiLine object
  65609. */
  65610. constructor(multiLine: MultiLine);
  65611. /** Gets or sets x coordinate */
  65612. x: string | number;
  65613. /** Gets or sets y coordinate */
  65614. y: string | number;
  65615. /** Gets or sets the control associated with this point */
  65616. control: BABYLON.Nullable<Control>;
  65617. /** Gets or sets the mesh associated with this point */
  65618. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65619. /** Resets links */
  65620. resetLinks(): void;
  65621. /**
  65622. * Gets a translation vector
  65623. * @returns the translation vector
  65624. */
  65625. translate(): BABYLON.Vector2;
  65626. private _translatePoint;
  65627. /** Release associated resources */
  65628. dispose(): void;
  65629. }
  65630. }
  65631. declare module BABYLON.GUI {
  65632. /**
  65633. * Class used to create multi line control
  65634. */
  65635. export class MultiLine extends Control {
  65636. name?: string | undefined;
  65637. private _lineWidth;
  65638. private _dash;
  65639. private _points;
  65640. private _minX;
  65641. private _minY;
  65642. private _maxX;
  65643. private _maxY;
  65644. /**
  65645. * Creates a new MultiLine
  65646. * @param name defines the control name
  65647. */
  65648. constructor(name?: string | undefined);
  65649. /** Gets or sets dash pattern */
  65650. dash: Array<number>;
  65651. /**
  65652. * Gets point stored at specified index
  65653. * @param index defines the index to look for
  65654. * @returns the requested point if found
  65655. */
  65656. getAt(index: number): MultiLinePoint;
  65657. /** Function called when a point is updated */
  65658. onPointUpdate: () => void;
  65659. /**
  65660. * Adds new points to the point collection
  65661. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65662. * @returns the list of created MultiLinePoint
  65663. */
  65664. add(...items: (AbstractMesh | Control | {
  65665. x: string | number;
  65666. y: string | number;
  65667. })[]): MultiLinePoint[];
  65668. /**
  65669. * Adds a new point to the point collection
  65670. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65671. * @returns the created MultiLinePoint
  65672. */
  65673. push(item?: (AbstractMesh | Control | {
  65674. x: string | number;
  65675. y: string | number;
  65676. })): MultiLinePoint;
  65677. /**
  65678. * Remove a specific value or point from the active point collection
  65679. * @param value defines the value or point to remove
  65680. */
  65681. remove(value: number | MultiLinePoint): void;
  65682. /**
  65683. * Resets this object to initial state (no point)
  65684. */
  65685. reset(): void;
  65686. /**
  65687. * Resets all links
  65688. */
  65689. resetLinks(): void;
  65690. /** Gets or sets line width */
  65691. lineWidth: number;
  65692. horizontalAlignment: number;
  65693. verticalAlignment: number;
  65694. protected _getTypeName(): string;
  65695. _draw(context: CanvasRenderingContext2D): void;
  65696. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65697. _measure(): void;
  65698. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65699. dispose(): void;
  65700. }
  65701. }
  65702. declare module BABYLON.GUI {
  65703. /**
  65704. * Class used to create radio button controls
  65705. */
  65706. export class RadioButton extends Control {
  65707. name?: string | undefined;
  65708. private _isChecked;
  65709. private _background;
  65710. private _checkSizeRatio;
  65711. private _thickness;
  65712. /** Gets or sets border thickness */
  65713. thickness: number;
  65714. /** Gets or sets group name */
  65715. group: string;
  65716. /** BABYLON.Observable raised when isChecked is changed */
  65717. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65718. /** Gets or sets a value indicating the ratio between overall size and check size */
  65719. checkSizeRatio: number;
  65720. /** Gets or sets background color */
  65721. background: string;
  65722. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65723. isChecked: boolean;
  65724. /**
  65725. * Creates a new RadioButton
  65726. * @param name defines the control name
  65727. */
  65728. constructor(name?: string | undefined);
  65729. protected _getTypeName(): string;
  65730. _draw(context: CanvasRenderingContext2D): void;
  65731. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65732. /**
  65733. * Utility function to easily create a radio button with a header
  65734. * @param title defines the label to use for the header
  65735. * @param group defines the group to use for the radio button
  65736. * @param isChecked defines the initial state of the radio button
  65737. * @param onValueChanged defines the callback to call when value changes
  65738. * @returns a StackPanel containing the radio button and a textBlock
  65739. */
  65740. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65741. }
  65742. }
  65743. declare module BABYLON.GUI {
  65744. /**
  65745. * Class used to create slider controls
  65746. */
  65747. export class BaseSlider extends Control {
  65748. name?: string | undefined;
  65749. protected _thumbWidth: ValueAndUnit;
  65750. private _minimum;
  65751. private _maximum;
  65752. private _value;
  65753. private _isVertical;
  65754. protected _barOffset: ValueAndUnit;
  65755. private _isThumbClamped;
  65756. protected _displayThumb: boolean;
  65757. private _step;
  65758. private _lastPointerDownID;
  65759. protected _effectiveBarOffset: number;
  65760. protected _renderLeft: number;
  65761. protected _renderTop: number;
  65762. protected _renderWidth: number;
  65763. protected _renderHeight: number;
  65764. protected _backgroundBoxLength: number;
  65765. protected _backgroundBoxThickness: number;
  65766. protected _effectiveThumbThickness: number;
  65767. /** BABYLON.Observable raised when the sldier value changes */
  65768. onValueChangedObservable: BABYLON.Observable<number>;
  65769. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65770. displayThumb: boolean;
  65771. /** Gets or sets a step to apply to values (0 by default) */
  65772. step: number;
  65773. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65774. barOffset: string | number;
  65775. /** Gets main bar offset in pixels*/
  65776. readonly barOffsetInPixels: number;
  65777. /** Gets or sets thumb width */
  65778. thumbWidth: string | number;
  65779. /** Gets thumb width in pixels */
  65780. readonly thumbWidthInPixels: number;
  65781. /** Gets or sets minimum value */
  65782. minimum: number;
  65783. /** Gets or sets maximum value */
  65784. maximum: number;
  65785. /** Gets or sets current value */
  65786. value: number;
  65787. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65788. isVertical: boolean;
  65789. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65790. isThumbClamped: boolean;
  65791. /**
  65792. * Creates a new BaseSlider
  65793. * @param name defines the control name
  65794. */
  65795. constructor(name?: string | undefined);
  65796. protected _getTypeName(): string;
  65797. protected _getThumbPosition(): number;
  65798. protected _getThumbThickness(type: string): number;
  65799. protected _prepareRenderingData(type: string): void;
  65800. private _pointerIsDown;
  65801. /** @hidden */
  65802. protected _updateValueFromPointer(x: number, y: number): void;
  65803. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65804. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65805. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65806. }
  65807. }
  65808. declare module BABYLON.GUI {
  65809. /**
  65810. * Class used to create slider controls
  65811. */
  65812. export class Slider extends BaseSlider {
  65813. name?: string | undefined;
  65814. private _background;
  65815. private _borderColor;
  65816. private _isThumbCircle;
  65817. protected _displayValueBar: boolean;
  65818. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65819. displayValueBar: boolean;
  65820. /** Gets or sets border color */
  65821. borderColor: string;
  65822. /** Gets or sets background color */
  65823. background: string;
  65824. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65825. isThumbCircle: boolean;
  65826. /**
  65827. * Creates a new Slider
  65828. * @param name defines the control name
  65829. */
  65830. constructor(name?: string | undefined);
  65831. protected _getTypeName(): string;
  65832. _draw(context: CanvasRenderingContext2D): void;
  65833. }
  65834. }
  65835. declare module BABYLON.GUI {
  65836. /** Class used to create a RadioGroup
  65837. * which contains groups of radio buttons
  65838. */
  65839. export class SelectorGroup {
  65840. /** name of SelectorGroup */
  65841. name: string;
  65842. private _groupPanel;
  65843. private _selectors;
  65844. private _groupHeader;
  65845. /**
  65846. * Creates a new SelectorGroup
  65847. * @param name of group, used as a group heading
  65848. */
  65849. constructor(
  65850. /** name of SelectorGroup */
  65851. name: string);
  65852. /** Gets the groupPanel of the SelectorGroup */
  65853. readonly groupPanel: StackPanel;
  65854. /** Gets the selectors array */
  65855. readonly selectors: StackPanel[];
  65856. /** Gets and sets the group header */
  65857. header: string;
  65858. /** @hidden */
  65859. private _addGroupHeader;
  65860. /** @hidden*/
  65861. _getSelector(selectorNb: number): StackPanel | undefined;
  65862. /** Removes the selector at the given position
  65863. * @param selectorNb the position of the selector within the group
  65864. */
  65865. removeSelector(selectorNb: number): void;
  65866. }
  65867. /** Class used to create a CheckboxGroup
  65868. * which contains groups of checkbox buttons
  65869. */
  65870. export class CheckboxGroup extends SelectorGroup {
  65871. /** Adds a checkbox as a control
  65872. * @param text is the label for the selector
  65873. * @param func is the function called when the Selector is checked
  65874. * @param checked is true when Selector is checked
  65875. */
  65876. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65877. /** @hidden */
  65878. _setSelectorLabel(selectorNb: number, label: string): void;
  65879. /** @hidden */
  65880. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65881. /** @hidden */
  65882. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65883. /** @hidden */
  65884. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65885. }
  65886. /** Class used to create a RadioGroup
  65887. * which contains groups of radio buttons
  65888. */
  65889. export class RadioGroup extends SelectorGroup {
  65890. private _selectNb;
  65891. /** Adds a radio button as a control
  65892. * @param label is the label for the selector
  65893. * @param func is the function called when the Selector is checked
  65894. * @param checked is true when Selector is checked
  65895. */
  65896. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65897. /** @hidden */
  65898. _setSelectorLabel(selectorNb: number, label: string): void;
  65899. /** @hidden */
  65900. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65901. /** @hidden */
  65902. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65903. /** @hidden */
  65904. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65905. }
  65906. /** Class used to create a SliderGroup
  65907. * which contains groups of slider buttons
  65908. */
  65909. export class SliderGroup extends SelectorGroup {
  65910. /**
  65911. * Adds a slider to the SelectorGroup
  65912. * @param label is the label for the SliderBar
  65913. * @param func is the function called when the Slider moves
  65914. * @param unit is a string describing the units used, eg degrees or metres
  65915. * @param min is the minimum value for the Slider
  65916. * @param max is the maximum value for the Slider
  65917. * @param value is the start value for the Slider between min and max
  65918. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65919. */
  65920. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65921. /** @hidden */
  65922. _setSelectorLabel(selectorNb: number, label: string): void;
  65923. /** @hidden */
  65924. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65925. /** @hidden */
  65926. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65927. /** @hidden */
  65928. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65929. }
  65930. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65931. * @see http://doc.babylonjs.com/how_to/selector
  65932. */
  65933. export class SelectionPanel extends Rectangle {
  65934. /** name of SelectionPanel */
  65935. name: string;
  65936. /** an array of SelectionGroups */
  65937. groups: SelectorGroup[];
  65938. private _panel;
  65939. private _buttonColor;
  65940. private _buttonBackground;
  65941. private _headerColor;
  65942. private _barColor;
  65943. private _barHeight;
  65944. private _spacerHeight;
  65945. private _labelColor;
  65946. private _groups;
  65947. private _bars;
  65948. /**
  65949. * Creates a new SelectionPanel
  65950. * @param name of SelectionPanel
  65951. * @param groups is an array of SelectionGroups
  65952. */
  65953. constructor(
  65954. /** name of SelectionPanel */
  65955. name: string,
  65956. /** an array of SelectionGroups */
  65957. groups?: SelectorGroup[]);
  65958. protected _getTypeName(): string;
  65959. /** Gets or sets the headerColor */
  65960. headerColor: string;
  65961. private _setHeaderColor;
  65962. /** Gets or sets the button color */
  65963. buttonColor: string;
  65964. private _setbuttonColor;
  65965. /** Gets or sets the label color */
  65966. labelColor: string;
  65967. private _setLabelColor;
  65968. /** Gets or sets the button background */
  65969. buttonBackground: string;
  65970. private _setButtonBackground;
  65971. /** Gets or sets the color of separator bar */
  65972. barColor: string;
  65973. private _setBarColor;
  65974. /** Gets or sets the height of separator bar */
  65975. barHeight: string;
  65976. private _setBarHeight;
  65977. /** Gets or sets the height of spacers*/
  65978. spacerHeight: string;
  65979. private _setSpacerHeight;
  65980. /** Adds a bar between groups */
  65981. private _addSpacer;
  65982. /** Add a group to the selection panel
  65983. * @param group is the selector group to add
  65984. */
  65985. addGroup(group: SelectorGroup): void;
  65986. /** Remove the group from the given position
  65987. * @param groupNb is the position of the group in the list
  65988. */
  65989. removeGroup(groupNb: number): void;
  65990. /** Change a group header label
  65991. * @param label is the new group header label
  65992. * @param groupNb is the number of the group to relabel
  65993. * */
  65994. setHeaderName(label: string, groupNb: number): void;
  65995. /** Change selector label to the one given
  65996. * @param label is the new selector label
  65997. * @param groupNb is the number of the groupcontaining the selector
  65998. * @param selectorNb is the number of the selector within a group to relabel
  65999. * */
  66000. relabel(label: string, groupNb: number, selectorNb: number): void;
  66001. /** For a given group position remove the selector at the given position
  66002. * @param groupNb is the number of the group to remove the selector from
  66003. * @param selectorNb is the number of the selector within the group
  66004. */
  66005. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66006. /** For a given group position of correct type add a checkbox button
  66007. * @param groupNb is the number of the group to remove the selector from
  66008. * @param label is the label for the selector
  66009. * @param func is the function called when the Selector is checked
  66010. * @param checked is true when Selector is checked
  66011. */
  66012. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66013. /** For a given group position of correct type add a radio button
  66014. * @param groupNb is the number of the group to remove the selector from
  66015. * @param label is the label for the selector
  66016. * @param func is the function called when the Selector is checked
  66017. * @param checked is true when Selector is checked
  66018. */
  66019. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66020. /**
  66021. * For a given slider group add a slider
  66022. * @param groupNb is the number of the group to add the slider to
  66023. * @param label is the label for the Slider
  66024. * @param func is the function called when the Slider moves
  66025. * @param unit is a string describing the units used, eg degrees or metres
  66026. * @param min is the minimum value for the Slider
  66027. * @param max is the maximum value for the Slider
  66028. * @param value is the start value for the Slider between min and max
  66029. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66030. */
  66031. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66032. }
  66033. }
  66034. declare module BABYLON.GUI {
  66035. /**
  66036. * Class used to hold a the container for ScrollViewer
  66037. * @hidden
  66038. */
  66039. export class _ScrollViewerWindow extends Container {
  66040. parentClientWidth: number;
  66041. parentClientHeight: number;
  66042. /**
  66043. * Creates a new ScrollViewerWindow
  66044. * @param name of ScrollViewerWindow
  66045. */
  66046. constructor(name?: string);
  66047. protected _getTypeName(): string;
  66048. /** @hidden */
  66049. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66050. protected _postMeasure(): void;
  66051. }
  66052. }
  66053. declare module BABYLON.GUI {
  66054. /**
  66055. * Class used to create slider controls
  66056. */
  66057. export class ScrollBar extends BaseSlider {
  66058. name?: string | undefined;
  66059. private _background;
  66060. private _borderColor;
  66061. private _thumbMeasure;
  66062. /** Gets or sets border color */
  66063. borderColor: string;
  66064. /** Gets or sets background color */
  66065. background: string;
  66066. /**
  66067. * Creates a new Slider
  66068. * @param name defines the control name
  66069. */
  66070. constructor(name?: string | undefined);
  66071. protected _getTypeName(): string;
  66072. protected _getThumbThickness(): number;
  66073. _draw(context: CanvasRenderingContext2D): void;
  66074. private _first;
  66075. private _originX;
  66076. private _originY;
  66077. /** @hidden */
  66078. protected _updateValueFromPointer(x: number, y: number): void;
  66079. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66080. }
  66081. }
  66082. declare module BABYLON.GUI {
  66083. /**
  66084. * Class used to hold a viewer window and sliders in a grid
  66085. */
  66086. export class ScrollViewer extends Rectangle {
  66087. private _grid;
  66088. private _horizontalBarSpace;
  66089. private _verticalBarSpace;
  66090. private _dragSpace;
  66091. private _horizontalBar;
  66092. private _verticalBar;
  66093. private _barColor;
  66094. private _barBackground;
  66095. private _barSize;
  66096. private _endLeft;
  66097. private _endTop;
  66098. private _window;
  66099. private _pointerIsOver;
  66100. private _wheelPrecision;
  66101. private _onPointerObserver;
  66102. private _clientWidth;
  66103. private _clientHeight;
  66104. /**
  66105. * Gets the horizontal scrollbar
  66106. */
  66107. readonly horizontalBar: ScrollBar;
  66108. /**
  66109. * Gets the vertical scrollbar
  66110. */
  66111. readonly verticalBar: ScrollBar;
  66112. /**
  66113. * Adds a new control to the current container
  66114. * @param control defines the control to add
  66115. * @returns the current container
  66116. */
  66117. addControl(control: BABYLON.Nullable<Control>): Container;
  66118. /**
  66119. * Removes a control from the current container
  66120. * @param control defines the control to remove
  66121. * @returns the current container
  66122. */
  66123. removeControl(control: Control): Container;
  66124. /** Gets the list of children */
  66125. readonly children: Control[];
  66126. _flagDescendantsAsMatrixDirty(): void;
  66127. /**
  66128. * Creates a new ScrollViewer
  66129. * @param name of ScrollViewer
  66130. */
  66131. constructor(name?: string);
  66132. /** Reset the scroll viewer window to initial size */
  66133. resetWindow(): void;
  66134. protected _getTypeName(): string;
  66135. private _buildClientSizes;
  66136. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66137. protected _postMeasure(): void;
  66138. /**
  66139. * Gets or sets the mouse wheel precision
  66140. * from 0 to 1 with a default value of 0.05
  66141. * */
  66142. wheelPrecision: number;
  66143. /** Gets or sets the bar color */
  66144. barColor: string;
  66145. /** Gets or sets the size of the bar */
  66146. barSize: number;
  66147. /** Gets or sets the bar background */
  66148. barBackground: string;
  66149. /** @hidden */
  66150. private _updateScroller;
  66151. _link(host: AdvancedDynamicTexture): void;
  66152. /** @hidden */
  66153. private _attachWheel;
  66154. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66155. /** Releases associated resources */
  66156. dispose(): void;
  66157. }
  66158. }
  66159. declare module BABYLON.GUI {
  66160. /** Class used to render a grid */
  66161. export class DisplayGrid extends Control {
  66162. name?: string | undefined;
  66163. private _cellWidth;
  66164. private _cellHeight;
  66165. private _minorLineTickness;
  66166. private _minorLineColor;
  66167. private _majorLineTickness;
  66168. private _majorLineColor;
  66169. private _majorLineFrequency;
  66170. private _background;
  66171. private _displayMajorLines;
  66172. private _displayMinorLines;
  66173. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66174. displayMinorLines: boolean;
  66175. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66176. displayMajorLines: boolean;
  66177. /** Gets or sets background color (Black by default) */
  66178. background: string;
  66179. /** Gets or sets the width of each cell (20 by default) */
  66180. cellWidth: number;
  66181. /** Gets or sets the height of each cell (20 by default) */
  66182. cellHeight: number;
  66183. /** Gets or sets the tickness of minor lines (1 by default) */
  66184. minorLineTickness: number;
  66185. /** Gets or sets the color of minor lines (DarkGray by default) */
  66186. minorLineColor: string;
  66187. /** Gets or sets the tickness of major lines (2 by default) */
  66188. majorLineTickness: number;
  66189. /** Gets or sets the color of major lines (White by default) */
  66190. majorLineColor: string;
  66191. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66192. majorLineFrequency: number;
  66193. /**
  66194. * Creates a new GridDisplayRectangle
  66195. * @param name defines the control name
  66196. */
  66197. constructor(name?: string | undefined);
  66198. _draw(context: CanvasRenderingContext2D): void;
  66199. protected _getTypeName(): string;
  66200. }
  66201. }
  66202. declare module BABYLON.GUI {
  66203. /**
  66204. * Class used to create slider controls based on images
  66205. */
  66206. export class ImageBasedSlider extends BaseSlider {
  66207. name?: string | undefined;
  66208. private _backgroundImage;
  66209. private _thumbImage;
  66210. private _valueBarImage;
  66211. private _tempMeasure;
  66212. displayThumb: boolean;
  66213. /**
  66214. * Gets or sets the image used to render the background
  66215. */
  66216. backgroundImage: Image;
  66217. /**
  66218. * Gets or sets the image used to render the value bar
  66219. */
  66220. valueBarImage: Image;
  66221. /**
  66222. * Gets or sets the image used to render the thumb
  66223. */
  66224. thumbImage: Image;
  66225. /**
  66226. * Creates a new ImageBasedSlider
  66227. * @param name defines the control name
  66228. */
  66229. constructor(name?: string | undefined);
  66230. protected _getTypeName(): string;
  66231. _draw(context: CanvasRenderingContext2D): void;
  66232. }
  66233. }
  66234. declare module BABYLON.GUI {
  66235. /**
  66236. * Forcing an export so that this code will execute
  66237. * @hidden
  66238. */
  66239. const name = "Statics";
  66240. }
  66241. declare module BABYLON.GUI {
  66242. /**
  66243. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66244. */
  66245. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66246. /**
  66247. * Define the instrumented AdvancedDynamicTexture.
  66248. */
  66249. texture: AdvancedDynamicTexture;
  66250. private _captureRenderTime;
  66251. private _renderTime;
  66252. private _captureLayoutTime;
  66253. private _layoutTime;
  66254. private _onBeginRenderObserver;
  66255. private _onEndRenderObserver;
  66256. private _onBeginLayoutObserver;
  66257. private _onEndLayoutObserver;
  66258. /**
  66259. * Gets the perf counter used to capture render time
  66260. */
  66261. readonly renderTimeCounter: BABYLON.PerfCounter;
  66262. /**
  66263. * Gets the perf counter used to capture layout time
  66264. */
  66265. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66266. /**
  66267. * Enable or disable the render time capture
  66268. */
  66269. captureRenderTime: boolean;
  66270. /**
  66271. * Enable or disable the layout time capture
  66272. */
  66273. captureLayoutTime: boolean;
  66274. /**
  66275. * Instantiates a new advanced dynamic texture instrumentation.
  66276. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66277. * @param texture Defines the AdvancedDynamicTexture to instrument
  66278. */
  66279. constructor(
  66280. /**
  66281. * Define the instrumented AdvancedDynamicTexture.
  66282. */
  66283. texture: AdvancedDynamicTexture);
  66284. /**
  66285. * Dispose and release associated resources.
  66286. */
  66287. dispose(): void;
  66288. }
  66289. }
  66290. declare module BABYLON.GUI {
  66291. /**
  66292. * Class used to load GUI via XML.
  66293. */
  66294. export class XmlLoader {
  66295. private _nodes;
  66296. private _nodeTypes;
  66297. private _isLoaded;
  66298. private _objectAttributes;
  66299. private _parentClass;
  66300. /**
  66301. * Create a new xml loader
  66302. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66303. */
  66304. constructor(parentClass?: null);
  66305. private _getChainElement;
  66306. private _getClassAttribute;
  66307. private _createGuiElement;
  66308. private _parseGrid;
  66309. private _parseElement;
  66310. private _prepareSourceElement;
  66311. private _parseElementsFromSource;
  66312. private _parseXml;
  66313. /**
  66314. * Gets if the loading has finished.
  66315. * @returns whether the loading has finished or not
  66316. */
  66317. isLoaded(): boolean;
  66318. /**
  66319. * Gets a loaded node / control by id.
  66320. * @param id the Controls id set in the xml
  66321. * @returns element of type Control
  66322. */
  66323. getNodeById(id: string): any;
  66324. /**
  66325. * Gets all loaded nodes / controls
  66326. * @returns Array of controls
  66327. */
  66328. getNodes(): any;
  66329. /**
  66330. * Initiates the xml layout loading
  66331. * @param xmlFile defines the xml layout to load
  66332. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66333. * @param callback defines the callback called on layout load.
  66334. */
  66335. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66336. }
  66337. }
  66338. declare module BABYLON.GUI {
  66339. /**
  66340. * Class used to create containers for controls
  66341. */
  66342. export class Container3D extends Control3D {
  66343. private _blockLayout;
  66344. /**
  66345. * Gets the list of child controls
  66346. */
  66347. protected _children: Control3D[];
  66348. /**
  66349. * Gets the list of child controls
  66350. */
  66351. readonly children: Array<Control3D>;
  66352. /**
  66353. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66354. * This is helpful to optimize layout operation when adding multiple children in a row
  66355. */
  66356. blockLayout: boolean;
  66357. /**
  66358. * Creates a new container
  66359. * @param name defines the container name
  66360. */
  66361. constructor(name?: string);
  66362. /**
  66363. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66364. * @returns the current container
  66365. */
  66366. updateLayout(): Container3D;
  66367. /**
  66368. * Gets a boolean indicating if the given control is in the children of this control
  66369. * @param control defines the control to check
  66370. * @returns true if the control is in the child list
  66371. */
  66372. containsControl(control: Control3D): boolean;
  66373. /**
  66374. * Adds a control to the children of this control
  66375. * @param control defines the control to add
  66376. * @returns the current container
  66377. */
  66378. addControl(control: Control3D): Container3D;
  66379. /**
  66380. * This function will be called everytime a new control is added
  66381. */
  66382. protected _arrangeChildren(): void;
  66383. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66384. /**
  66385. * Removes a control from the children of this control
  66386. * @param control defines the control to remove
  66387. * @returns the current container
  66388. */
  66389. removeControl(control: Control3D): Container3D;
  66390. protected _getTypeName(): string;
  66391. /**
  66392. * Releases all associated resources
  66393. */
  66394. dispose(): void;
  66395. /** Control rotation will remain unchanged */
  66396. static readonly UNSET_ORIENTATION: number;
  66397. /** Control will rotate to make it look at sphere central axis */
  66398. static readonly FACEORIGIN_ORIENTATION: number;
  66399. /** Control will rotate to make it look back at sphere central axis */
  66400. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66401. /** Control will rotate to look at z axis (0, 0, 1) */
  66402. static readonly FACEFORWARD_ORIENTATION: number;
  66403. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66404. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66405. }
  66406. }
  66407. declare module BABYLON.GUI {
  66408. /**
  66409. * Class used to manage 3D user interface
  66410. * @see http://doc.babylonjs.com/how_to/gui3d
  66411. */
  66412. export class GUI3DManager implements BABYLON.IDisposable {
  66413. private _scene;
  66414. private _sceneDisposeObserver;
  66415. private _utilityLayer;
  66416. private _rootContainer;
  66417. private _pointerObserver;
  66418. private _pointerOutObserver;
  66419. /** @hidden */
  66420. _lastPickedControl: Control3D;
  66421. /** @hidden */
  66422. _lastControlOver: {
  66423. [pointerId: number]: Control3D;
  66424. };
  66425. /** @hidden */
  66426. _lastControlDown: {
  66427. [pointerId: number]: Control3D;
  66428. };
  66429. /**
  66430. * BABYLON.Observable raised when the point picked by the pointer events changed
  66431. */
  66432. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66433. /** @hidden */
  66434. _sharedMaterials: {
  66435. [key: string]: BABYLON.Material;
  66436. };
  66437. /** Gets the hosting scene */
  66438. readonly scene: BABYLON.Scene;
  66439. /** Gets associated utility layer */
  66440. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66441. /**
  66442. * Creates a new GUI3DManager
  66443. * @param scene
  66444. */
  66445. constructor(scene?: BABYLON.Scene);
  66446. private _handlePointerOut;
  66447. private _doPicking;
  66448. /**
  66449. * Gets the root container
  66450. */
  66451. readonly rootContainer: Container3D;
  66452. /**
  66453. * Gets a boolean indicating if the given control is in the root child list
  66454. * @param control defines the control to check
  66455. * @returns true if the control is in the root child list
  66456. */
  66457. containsControl(control: Control3D): boolean;
  66458. /**
  66459. * Adds a control to the root child list
  66460. * @param control defines the control to add
  66461. * @returns the current manager
  66462. */
  66463. addControl(control: Control3D): GUI3DManager;
  66464. /**
  66465. * Removes a control from the root child list
  66466. * @param control defines the control to remove
  66467. * @returns the current container
  66468. */
  66469. removeControl(control: Control3D): GUI3DManager;
  66470. /**
  66471. * Releases all associated resources
  66472. */
  66473. dispose(): void;
  66474. }
  66475. }
  66476. declare module BABYLON.GUI {
  66477. /**
  66478. * Class used to transport BABYLON.Vector3 information for pointer events
  66479. */
  66480. export class Vector3WithInfo extends BABYLON.Vector3 {
  66481. /** defines the current mouse button index */
  66482. buttonIndex: number;
  66483. /**
  66484. * Creates a new Vector3WithInfo
  66485. * @param source defines the vector3 data to transport
  66486. * @param buttonIndex defines the current mouse button index
  66487. */
  66488. constructor(source: BABYLON.Vector3,
  66489. /** defines the current mouse button index */
  66490. buttonIndex?: number);
  66491. }
  66492. }
  66493. declare module BABYLON.GUI {
  66494. /**
  66495. * Class used as base class for controls
  66496. */
  66497. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66498. /** Defines the control name */
  66499. name?: string | undefined;
  66500. /** @hidden */
  66501. _host: GUI3DManager;
  66502. private _node;
  66503. private _downCount;
  66504. private _enterCount;
  66505. private _downPointerIds;
  66506. private _isVisible;
  66507. /** Gets or sets the control position in world space */
  66508. position: BABYLON.Vector3;
  66509. /** Gets or sets the control scaling in world space */
  66510. scaling: BABYLON.Vector3;
  66511. /** Callback used to start pointer enter animation */
  66512. pointerEnterAnimation: () => void;
  66513. /** Callback used to start pointer out animation */
  66514. pointerOutAnimation: () => void;
  66515. /** Callback used to start pointer down animation */
  66516. pointerDownAnimation: () => void;
  66517. /** Callback used to start pointer up animation */
  66518. pointerUpAnimation: () => void;
  66519. /**
  66520. * An event triggered when the pointer move over the control
  66521. */
  66522. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66523. /**
  66524. * An event triggered when the pointer move out of the control
  66525. */
  66526. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66527. /**
  66528. * An event triggered when the pointer taps the control
  66529. */
  66530. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66531. /**
  66532. * An event triggered when pointer is up
  66533. */
  66534. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66535. /**
  66536. * An event triggered when a control is clicked on (with a mouse)
  66537. */
  66538. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66539. /**
  66540. * An event triggered when pointer enters the control
  66541. */
  66542. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66543. /**
  66544. * Gets or sets the parent container
  66545. */
  66546. parent: BABYLON.Nullable<Container3D>;
  66547. private _behaviors;
  66548. /**
  66549. * Gets the list of attached behaviors
  66550. * @see http://doc.babylonjs.com/features/behaviour
  66551. */
  66552. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66553. /**
  66554. * Attach a behavior to the control
  66555. * @see http://doc.babylonjs.com/features/behaviour
  66556. * @param behavior defines the behavior to attach
  66557. * @returns the current control
  66558. */
  66559. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66560. /**
  66561. * Remove an attached behavior
  66562. * @see http://doc.babylonjs.com/features/behaviour
  66563. * @param behavior defines the behavior to attach
  66564. * @returns the current control
  66565. */
  66566. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66567. /**
  66568. * Gets an attached behavior by name
  66569. * @param name defines the name of the behavior to look for
  66570. * @see http://doc.babylonjs.com/features/behaviour
  66571. * @returns null if behavior was not found else the requested behavior
  66572. */
  66573. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66574. /** Gets or sets a boolean indicating if the control is visible */
  66575. isVisible: boolean;
  66576. /**
  66577. * Creates a new control
  66578. * @param name defines the control name
  66579. */
  66580. constructor(
  66581. /** Defines the control name */
  66582. name?: string | undefined);
  66583. /**
  66584. * Gets a string representing the class name
  66585. */
  66586. readonly typeName: string;
  66587. /**
  66588. * Get the current class name of the control.
  66589. * @returns current class name
  66590. */
  66591. getClassName(): string;
  66592. protected _getTypeName(): string;
  66593. /**
  66594. * Gets the transform node used by this control
  66595. */
  66596. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66597. /**
  66598. * Gets the mesh used to render this control
  66599. */
  66600. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66601. /**
  66602. * Link the control as child of the given node
  66603. * @param node defines the node to link to. Use null to unlink the control
  66604. * @returns the current control
  66605. */
  66606. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66607. /** @hidden **/
  66608. _prepareNode(scene: BABYLON.Scene): void;
  66609. /**
  66610. * Node creation.
  66611. * Can be overriden by children
  66612. * @param scene defines the scene where the node must be attached
  66613. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66614. */
  66615. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66616. /**
  66617. * Affect a material to the given mesh
  66618. * @param mesh defines the mesh which will represent the control
  66619. */
  66620. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66621. /** @hidden */
  66622. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66623. /** @hidden */
  66624. _onPointerEnter(target: Control3D): boolean;
  66625. /** @hidden */
  66626. _onPointerOut(target: Control3D): void;
  66627. /** @hidden */
  66628. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66629. /** @hidden */
  66630. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66631. /** @hidden */
  66632. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66633. /** @hidden */
  66634. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66635. /** @hidden */
  66636. _disposeNode(): void;
  66637. /**
  66638. * Releases all associated resources
  66639. */
  66640. dispose(): void;
  66641. }
  66642. }
  66643. declare module BABYLON.GUI {
  66644. /**
  66645. * Class used as a root to all buttons
  66646. */
  66647. export class AbstractButton3D extends Control3D {
  66648. /**
  66649. * Creates a new button
  66650. * @param name defines the control name
  66651. */
  66652. constructor(name?: string);
  66653. protected _getTypeName(): string;
  66654. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66655. }
  66656. }
  66657. declare module BABYLON.GUI {
  66658. /**
  66659. * Class used to create a button in 3D
  66660. */
  66661. export class Button3D extends AbstractButton3D {
  66662. /** @hidden */
  66663. protected _currentMaterial: BABYLON.Material;
  66664. private _facadeTexture;
  66665. private _content;
  66666. private _contentResolution;
  66667. private _contentScaleRatio;
  66668. /**
  66669. * Gets or sets the texture resolution used to render content (512 by default)
  66670. */
  66671. contentResolution: BABYLON.int;
  66672. /**
  66673. * Gets or sets the texture scale ratio used to render content (2 by default)
  66674. */
  66675. contentScaleRatio: number;
  66676. protected _disposeFacadeTexture(): void;
  66677. protected _resetContent(): void;
  66678. /**
  66679. * Creates a new button
  66680. * @param name defines the control name
  66681. */
  66682. constructor(name?: string);
  66683. /**
  66684. * Gets or sets the GUI 2D content used to display the button's facade
  66685. */
  66686. content: Control;
  66687. /**
  66688. * Apply the facade texture (created from the content property).
  66689. * This function can be overloaded by child classes
  66690. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66691. */
  66692. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66693. protected _getTypeName(): string;
  66694. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66695. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66696. /**
  66697. * Releases all associated resources
  66698. */
  66699. dispose(): void;
  66700. }
  66701. }
  66702. declare module BABYLON.GUI {
  66703. /**
  66704. * Abstract class used to create a container panel deployed on the surface of a volume
  66705. */
  66706. export abstract class VolumeBasedPanel extends Container3D {
  66707. private _columns;
  66708. private _rows;
  66709. private _rowThenColum;
  66710. private _orientation;
  66711. protected _cellWidth: number;
  66712. protected _cellHeight: number;
  66713. /**
  66714. * Gets or sets the distance between elements
  66715. */
  66716. margin: number;
  66717. /**
  66718. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66719. * | Value | Type | Description |
  66720. * | ----- | ----------------------------------- | ----------- |
  66721. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66722. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66723. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66724. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66725. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66726. */
  66727. orientation: number;
  66728. /**
  66729. * Gets or sets the number of columns requested (10 by default).
  66730. * The panel will automatically compute the number of rows based on number of child controls.
  66731. */
  66732. columns: BABYLON.int;
  66733. /**
  66734. * Gets or sets a the number of rows requested.
  66735. * The panel will automatically compute the number of columns based on number of child controls.
  66736. */
  66737. rows: BABYLON.int;
  66738. /**
  66739. * Creates new VolumeBasedPanel
  66740. */
  66741. constructor();
  66742. protected _arrangeChildren(): void;
  66743. /** Child classes must implement this function to provide correct control positioning */
  66744. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66745. /** Child classes can implement this function to provide additional processing */
  66746. protected _finalProcessing(): void;
  66747. }
  66748. }
  66749. declare module BABYLON.GUI {
  66750. /**
  66751. * Class used to create a container panel deployed on the surface of a cylinder
  66752. */
  66753. export class CylinderPanel extends VolumeBasedPanel {
  66754. private _radius;
  66755. /**
  66756. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66757. */
  66758. radius: BABYLON.float;
  66759. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66760. private _cylindricalMapping;
  66761. }
  66762. }
  66763. declare module BABYLON.GUI {
  66764. /** @hidden */
  66765. export var fluentVertexShader: {
  66766. name: string;
  66767. shader: string;
  66768. };
  66769. }
  66770. declare module BABYLON.GUI {
  66771. /** @hidden */
  66772. export var fluentPixelShader: {
  66773. name: string;
  66774. shader: string;
  66775. };
  66776. }
  66777. declare module BABYLON.GUI {
  66778. /** @hidden */
  66779. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66780. INNERGLOW: boolean;
  66781. BORDER: boolean;
  66782. HOVERLIGHT: boolean;
  66783. TEXTURE: boolean;
  66784. constructor();
  66785. }
  66786. /**
  66787. * Class used to render controls with fluent desgin
  66788. */
  66789. export class FluentMaterial extends BABYLON.PushMaterial {
  66790. /**
  66791. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66792. */
  66793. innerGlowColorIntensity: number;
  66794. /**
  66795. * Gets or sets the inner glow color (white by default)
  66796. */
  66797. innerGlowColor: BABYLON.Color3;
  66798. /**
  66799. * Gets or sets alpha value (default is 1.0)
  66800. */
  66801. alpha: number;
  66802. /**
  66803. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66804. */
  66805. albedoColor: BABYLON.Color3;
  66806. /**
  66807. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66808. */
  66809. renderBorders: boolean;
  66810. /**
  66811. * Gets or sets border width (default is 0.5)
  66812. */
  66813. borderWidth: number;
  66814. /**
  66815. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66816. */
  66817. edgeSmoothingValue: number;
  66818. /**
  66819. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66820. */
  66821. borderMinValue: number;
  66822. /**
  66823. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66824. */
  66825. renderHoverLight: boolean;
  66826. /**
  66827. * Gets or sets the radius used to render the hover light (default is 1.0)
  66828. */
  66829. hoverRadius: number;
  66830. /**
  66831. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66832. */
  66833. hoverColor: BABYLON.Color4;
  66834. /**
  66835. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66836. */
  66837. hoverPosition: BABYLON.Vector3;
  66838. private _albedoTexture;
  66839. /** Gets or sets the texture to use for albedo color */
  66840. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66841. /**
  66842. * Creates a new Fluent material
  66843. * @param name defines the name of the material
  66844. * @param scene defines the hosting scene
  66845. */
  66846. constructor(name: string, scene: BABYLON.Scene);
  66847. needAlphaBlending(): boolean;
  66848. needAlphaTesting(): boolean;
  66849. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66850. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66851. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66852. getActiveTextures(): BABYLON.BaseTexture[];
  66853. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66854. dispose(forceDisposeEffect?: boolean): void;
  66855. clone(name: string): FluentMaterial;
  66856. serialize(): any;
  66857. getClassName(): string;
  66858. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66859. }
  66860. }
  66861. declare module BABYLON.GUI {
  66862. /**
  66863. * Class used to create a holographic button in 3D
  66864. */
  66865. export class HolographicButton extends Button3D {
  66866. private _backPlate;
  66867. private _textPlate;
  66868. private _frontPlate;
  66869. private _text;
  66870. private _imageUrl;
  66871. private _shareMaterials;
  66872. private _frontMaterial;
  66873. private _backMaterial;
  66874. private _plateMaterial;
  66875. private _pickedPointObserver;
  66876. private _tooltipFade;
  66877. private _tooltipTextBlock;
  66878. private _tooltipTexture;
  66879. private _tooltipMesh;
  66880. private _tooltipHoverObserver;
  66881. private _tooltipOutObserver;
  66882. private _disposeTooltip;
  66883. /**
  66884. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66885. */
  66886. tooltipText: BABYLON.Nullable<string>;
  66887. /**
  66888. * Gets or sets text for the button
  66889. */
  66890. text: string;
  66891. /**
  66892. * Gets or sets the image url for the button
  66893. */
  66894. imageUrl: string;
  66895. /**
  66896. * Gets the back material used by this button
  66897. */
  66898. readonly backMaterial: FluentMaterial;
  66899. /**
  66900. * Gets the front material used by this button
  66901. */
  66902. readonly frontMaterial: FluentMaterial;
  66903. /**
  66904. * Gets the plate material used by this button
  66905. */
  66906. readonly plateMaterial: BABYLON.StandardMaterial;
  66907. /**
  66908. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66909. */
  66910. readonly shareMaterials: boolean;
  66911. /**
  66912. * Creates a new button
  66913. * @param name defines the control name
  66914. */
  66915. constructor(name?: string, shareMaterials?: boolean);
  66916. protected _getTypeName(): string;
  66917. private _rebuildContent;
  66918. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66919. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66920. private _createBackMaterial;
  66921. private _createFrontMaterial;
  66922. private _createPlateMaterial;
  66923. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66924. /**
  66925. * Releases all associated resources
  66926. */
  66927. dispose(): void;
  66928. }
  66929. }
  66930. declare module BABYLON.GUI {
  66931. /**
  66932. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66933. */
  66934. export class MeshButton3D extends Button3D {
  66935. /** @hidden */
  66936. protected _currentMesh: BABYLON.Mesh;
  66937. /**
  66938. * Creates a new 3D button based on a mesh
  66939. * @param mesh mesh to become a 3D button
  66940. * @param name defines the control name
  66941. */
  66942. constructor(mesh: BABYLON.Mesh, name?: string);
  66943. protected _getTypeName(): string;
  66944. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66945. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66946. }
  66947. }
  66948. declare module BABYLON.GUI {
  66949. /**
  66950. * Class used to create a container panel deployed on the surface of a plane
  66951. */
  66952. export class PlanePanel extends VolumeBasedPanel {
  66953. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66954. }
  66955. }
  66956. declare module BABYLON.GUI {
  66957. /**
  66958. * Class used to create a container panel where items get randomized planar mapping
  66959. */
  66960. export class ScatterPanel extends VolumeBasedPanel {
  66961. private _iteration;
  66962. /**
  66963. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66964. */
  66965. iteration: BABYLON.float;
  66966. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66967. private _scatterMapping;
  66968. protected _finalProcessing(): void;
  66969. }
  66970. }
  66971. declare module BABYLON.GUI {
  66972. /**
  66973. * Class used to create a container panel deployed on the surface of a sphere
  66974. */
  66975. export class SpherePanel extends VolumeBasedPanel {
  66976. private _radius;
  66977. /**
  66978. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66979. */
  66980. radius: BABYLON.float;
  66981. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66982. private _sphericalMapping;
  66983. }
  66984. }
  66985. declare module BABYLON.GUI {
  66986. /**
  66987. * Class used to create a stack panel in 3D on XY plane
  66988. */
  66989. export class StackPanel3D extends Container3D {
  66990. private _isVertical;
  66991. /**
  66992. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66993. */
  66994. isVertical: boolean;
  66995. /**
  66996. * Gets or sets the distance between elements
  66997. */
  66998. margin: number;
  66999. /**
  67000. * Creates new StackPanel
  67001. * @param isVertical
  67002. */
  67003. constructor(isVertical?: boolean);
  67004. protected _arrangeChildren(): void;
  67005. }
  67006. }
  67007. declare module BABYLON {
  67008. /**
  67009. * Mode that determines the coordinate system to use.
  67010. */
  67011. export enum GLTFLoaderCoordinateSystemMode {
  67012. /**
  67013. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67014. */
  67015. AUTO = 0,
  67016. /**
  67017. * Sets the useRightHandedSystem flag on the scene.
  67018. */
  67019. FORCE_RIGHT_HANDED = 1
  67020. }
  67021. /**
  67022. * Mode that determines what animations will start.
  67023. */
  67024. export enum GLTFLoaderAnimationStartMode {
  67025. /**
  67026. * No animation will start.
  67027. */
  67028. NONE = 0,
  67029. /**
  67030. * The first animation will start.
  67031. */
  67032. FIRST = 1,
  67033. /**
  67034. * All animations will start.
  67035. */
  67036. ALL = 2
  67037. }
  67038. /**
  67039. * Interface that contains the data for the glTF asset.
  67040. */
  67041. export interface IGLTFLoaderData {
  67042. /**
  67043. * Object that represents the glTF JSON.
  67044. */
  67045. json: Object;
  67046. /**
  67047. * The BIN chunk of a binary glTF.
  67048. */
  67049. bin: Nullable<ArrayBufferView>;
  67050. }
  67051. /**
  67052. * Interface for extending the loader.
  67053. */
  67054. export interface IGLTFLoaderExtension {
  67055. /**
  67056. * The name of this extension.
  67057. */
  67058. readonly name: string;
  67059. /**
  67060. * Defines whether this extension is enabled.
  67061. */
  67062. enabled: boolean;
  67063. }
  67064. /**
  67065. * Loader state.
  67066. */
  67067. export enum GLTFLoaderState {
  67068. /**
  67069. * The asset is loading.
  67070. */
  67071. LOADING = 0,
  67072. /**
  67073. * The asset is ready for rendering.
  67074. */
  67075. READY = 1,
  67076. /**
  67077. * The asset is completely loaded.
  67078. */
  67079. COMPLETE = 2
  67080. }
  67081. /** @hidden */
  67082. export interface IGLTFLoader extends IDisposable {
  67083. readonly state: Nullable<GLTFLoaderState>;
  67084. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67085. meshes: AbstractMesh[];
  67086. particleSystems: IParticleSystem[];
  67087. skeletons: Skeleton[];
  67088. animationGroups: AnimationGroup[];
  67089. }>;
  67090. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67091. }
  67092. /**
  67093. * File loader for loading glTF files into a scene.
  67094. */
  67095. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67096. /** @hidden */
  67097. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67098. /** @hidden */
  67099. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67100. /**
  67101. * Raised when the asset has been parsed
  67102. */
  67103. onParsedObservable: Observable<IGLTFLoaderData>;
  67104. private _onParsedObserver;
  67105. /**
  67106. * Raised when the asset has been parsed
  67107. */
  67108. onParsed: (loaderData: IGLTFLoaderData) => void;
  67109. /**
  67110. * 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.
  67111. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67112. * Defaults to true.
  67113. * @hidden
  67114. */
  67115. static IncrementalLoading: boolean;
  67116. /**
  67117. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67118. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67119. * @hidden
  67120. */
  67121. static HomogeneousCoordinates: boolean;
  67122. /**
  67123. * The coordinate system mode. Defaults to AUTO.
  67124. */
  67125. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67126. /**
  67127. * The animation start mode. Defaults to FIRST.
  67128. */
  67129. animationStartMode: GLTFLoaderAnimationStartMode;
  67130. /**
  67131. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67132. */
  67133. compileMaterials: boolean;
  67134. /**
  67135. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67136. */
  67137. useClipPlane: boolean;
  67138. /**
  67139. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67140. */
  67141. compileShadowGenerators: boolean;
  67142. /**
  67143. * Defines if the Alpha blended materials are only applied as coverage.
  67144. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67145. * If true, no extra effects are applied to transparent pixels.
  67146. */
  67147. transparencyAsCoverage: boolean;
  67148. /**
  67149. * Function called before loading a url referenced by the asset.
  67150. */
  67151. preprocessUrlAsync: (url: string) => Promise<string>;
  67152. /**
  67153. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67154. */
  67155. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67156. private _onMeshLoadedObserver;
  67157. /**
  67158. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67159. */
  67160. onMeshLoaded: (mesh: AbstractMesh) => void;
  67161. /**
  67162. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67163. */
  67164. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67165. private _onTextureLoadedObserver;
  67166. /**
  67167. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67168. */
  67169. onTextureLoaded: (texture: BaseTexture) => void;
  67170. /**
  67171. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67172. */
  67173. readonly onMaterialLoadedObservable: Observable<Material>;
  67174. private _onMaterialLoadedObserver;
  67175. /**
  67176. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67177. */
  67178. onMaterialLoaded: (material: Material) => void;
  67179. /**
  67180. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67181. */
  67182. readonly onCameraLoadedObservable: Observable<Camera>;
  67183. private _onCameraLoadedObserver;
  67184. /**
  67185. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67186. */
  67187. onCameraLoaded: (camera: Camera) => void;
  67188. /**
  67189. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67190. * For assets with LODs, raised when all of the LODs are complete.
  67191. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67192. */
  67193. readonly onCompleteObservable: Observable<void>;
  67194. private _onCompleteObserver;
  67195. /**
  67196. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67197. * For assets with LODs, raised when all of the LODs are complete.
  67198. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67199. */
  67200. onComplete: () => void;
  67201. /**
  67202. * Observable raised when an error occurs.
  67203. */
  67204. readonly onErrorObservable: Observable<any>;
  67205. private _onErrorObserver;
  67206. /**
  67207. * Callback raised when an error occurs.
  67208. */
  67209. onError: (reason: any) => void;
  67210. /**
  67211. * Observable raised after the loader is disposed.
  67212. */
  67213. readonly onDisposeObservable: Observable<void>;
  67214. private _onDisposeObserver;
  67215. /**
  67216. * Callback raised after the loader is disposed.
  67217. */
  67218. onDispose: () => void;
  67219. /**
  67220. * Observable raised after a loader extension is created.
  67221. * Set additional options for a loader extension in this event.
  67222. */
  67223. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67224. private _onExtensionLoadedObserver;
  67225. /**
  67226. * Callback raised after a loader extension is created.
  67227. */
  67228. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67229. /**
  67230. * Defines if the loader logging is enabled.
  67231. */
  67232. loggingEnabled: boolean;
  67233. /**
  67234. * Defines if the loader should capture performance counters.
  67235. */
  67236. capturePerformanceCounters: boolean;
  67237. /**
  67238. * Defines if the loader should validate the asset.
  67239. */
  67240. validate: boolean;
  67241. /**
  67242. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67243. */
  67244. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67245. private _onValidatedObserver;
  67246. /**
  67247. * Callback raised after a loader extension is created.
  67248. */
  67249. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67250. private _loader;
  67251. /**
  67252. * Name of the loader ("gltf")
  67253. */
  67254. name: string;
  67255. /**
  67256. * Supported file extensions of the loader (.gltf, .glb)
  67257. */
  67258. extensions: ISceneLoaderPluginExtensions;
  67259. /**
  67260. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67261. */
  67262. dispose(): void;
  67263. /** @hidden */
  67264. _clear(): void;
  67265. /**
  67266. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67267. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67268. * @param scene the scene the meshes should be added to
  67269. * @param data the glTF data to load
  67270. * @param rootUrl root url to load from
  67271. * @param onProgress event that fires when loading progress has occured
  67272. * @param fileName Defines the name of the file to load
  67273. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67274. */
  67275. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67276. meshes: AbstractMesh[];
  67277. particleSystems: IParticleSystem[];
  67278. skeletons: Skeleton[];
  67279. animationGroups: AnimationGroup[];
  67280. }>;
  67281. /**
  67282. * Imports all objects from the loaded glTF data and adds them to the scene
  67283. * @param scene the scene the objects should be added to
  67284. * @param data the glTF data to load
  67285. * @param rootUrl root url to load from
  67286. * @param onProgress event that fires when loading progress has occured
  67287. * @param fileName Defines the name of the file to load
  67288. * @returns a promise which completes when objects have been loaded to the scene
  67289. */
  67290. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67291. /**
  67292. * Load into an asset container.
  67293. * @param scene The scene to load into
  67294. * @param data The data to import
  67295. * @param rootUrl The root url for scene and resources
  67296. * @param onProgress The callback when the load progresses
  67297. * @param fileName Defines the name of the file to load
  67298. * @returns The loaded asset container
  67299. */
  67300. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67301. /**
  67302. * If the data string can be loaded directly.
  67303. * @param data string contianing the file data
  67304. * @returns if the data can be loaded directly
  67305. */
  67306. canDirectLoad(data: string): boolean;
  67307. /**
  67308. * Rewrites a url by combining a root url and response url.
  67309. */
  67310. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67311. /**
  67312. * Instantiates a glTF file loader plugin.
  67313. * @returns the created plugin
  67314. */
  67315. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67316. /**
  67317. * The loader state or null if the loader is not active.
  67318. */
  67319. readonly loaderState: Nullable<GLTFLoaderState>;
  67320. /**
  67321. * Returns a promise that resolves when the asset is completely loaded.
  67322. * @returns a promise that resolves when the asset is completely loaded.
  67323. */
  67324. whenCompleteAsync(): Promise<void>;
  67325. private _parseAsync;
  67326. private _validateAsync;
  67327. private _getLoader;
  67328. private _unpackBinary;
  67329. private _unpackBinaryV1;
  67330. private _unpackBinaryV2;
  67331. private static _parseVersion;
  67332. private static _compareVersion;
  67333. private static _decodeBufferToText;
  67334. private static readonly _logSpaces;
  67335. private _logIndentLevel;
  67336. private _loggingEnabled;
  67337. /** @hidden */
  67338. _log: (message: string) => void;
  67339. /** @hidden */
  67340. _logOpen(message: string): void;
  67341. /** @hidden */
  67342. _logClose(): void;
  67343. private _logEnabled;
  67344. private _logDisabled;
  67345. private _capturePerformanceCounters;
  67346. /** @hidden */
  67347. _startPerformanceCounter: (counterName: string) => void;
  67348. /** @hidden */
  67349. _endPerformanceCounter: (counterName: string) => void;
  67350. private _startPerformanceCounterEnabled;
  67351. private _startPerformanceCounterDisabled;
  67352. private _endPerformanceCounterEnabled;
  67353. private _endPerformanceCounterDisabled;
  67354. }
  67355. }
  67356. declare module BABYLON.GLTF1 {
  67357. /**
  67358. * Enums
  67359. * @hidden
  67360. */
  67361. export enum EComponentType {
  67362. BYTE = 5120,
  67363. UNSIGNED_BYTE = 5121,
  67364. SHORT = 5122,
  67365. UNSIGNED_SHORT = 5123,
  67366. FLOAT = 5126
  67367. }
  67368. /** @hidden */
  67369. export enum EShaderType {
  67370. FRAGMENT = 35632,
  67371. VERTEX = 35633
  67372. }
  67373. /** @hidden */
  67374. export enum EParameterType {
  67375. BYTE = 5120,
  67376. UNSIGNED_BYTE = 5121,
  67377. SHORT = 5122,
  67378. UNSIGNED_SHORT = 5123,
  67379. INT = 5124,
  67380. UNSIGNED_INT = 5125,
  67381. FLOAT = 5126,
  67382. FLOAT_VEC2 = 35664,
  67383. FLOAT_VEC3 = 35665,
  67384. FLOAT_VEC4 = 35666,
  67385. INT_VEC2 = 35667,
  67386. INT_VEC3 = 35668,
  67387. INT_VEC4 = 35669,
  67388. BOOL = 35670,
  67389. BOOL_VEC2 = 35671,
  67390. BOOL_VEC3 = 35672,
  67391. BOOL_VEC4 = 35673,
  67392. FLOAT_MAT2 = 35674,
  67393. FLOAT_MAT3 = 35675,
  67394. FLOAT_MAT4 = 35676,
  67395. SAMPLER_2D = 35678
  67396. }
  67397. /** @hidden */
  67398. export enum ETextureWrapMode {
  67399. CLAMP_TO_EDGE = 33071,
  67400. MIRRORED_REPEAT = 33648,
  67401. REPEAT = 10497
  67402. }
  67403. /** @hidden */
  67404. export enum ETextureFilterType {
  67405. NEAREST = 9728,
  67406. LINEAR = 9728,
  67407. NEAREST_MIPMAP_NEAREST = 9984,
  67408. LINEAR_MIPMAP_NEAREST = 9985,
  67409. NEAREST_MIPMAP_LINEAR = 9986,
  67410. LINEAR_MIPMAP_LINEAR = 9987
  67411. }
  67412. /** @hidden */
  67413. export enum ETextureFormat {
  67414. ALPHA = 6406,
  67415. RGB = 6407,
  67416. RGBA = 6408,
  67417. LUMINANCE = 6409,
  67418. LUMINANCE_ALPHA = 6410
  67419. }
  67420. /** @hidden */
  67421. export enum ECullingType {
  67422. FRONT = 1028,
  67423. BACK = 1029,
  67424. FRONT_AND_BACK = 1032
  67425. }
  67426. /** @hidden */
  67427. export enum EBlendingFunction {
  67428. ZERO = 0,
  67429. ONE = 1,
  67430. SRC_COLOR = 768,
  67431. ONE_MINUS_SRC_COLOR = 769,
  67432. DST_COLOR = 774,
  67433. ONE_MINUS_DST_COLOR = 775,
  67434. SRC_ALPHA = 770,
  67435. ONE_MINUS_SRC_ALPHA = 771,
  67436. DST_ALPHA = 772,
  67437. ONE_MINUS_DST_ALPHA = 773,
  67438. CONSTANT_COLOR = 32769,
  67439. ONE_MINUS_CONSTANT_COLOR = 32770,
  67440. CONSTANT_ALPHA = 32771,
  67441. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67442. SRC_ALPHA_SATURATE = 776
  67443. }
  67444. /** @hidden */
  67445. export interface IGLTFProperty {
  67446. extensions?: {
  67447. [key: string]: any;
  67448. };
  67449. extras?: Object;
  67450. }
  67451. /** @hidden */
  67452. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67453. name?: string;
  67454. }
  67455. /** @hidden */
  67456. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67457. bufferView: string;
  67458. byteOffset: number;
  67459. byteStride: number;
  67460. count: number;
  67461. type: string;
  67462. componentType: EComponentType;
  67463. max?: number[];
  67464. min?: number[];
  67465. name?: string;
  67466. }
  67467. /** @hidden */
  67468. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67469. buffer: string;
  67470. byteOffset: number;
  67471. byteLength: number;
  67472. byteStride: number;
  67473. target?: number;
  67474. }
  67475. /** @hidden */
  67476. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67477. uri: string;
  67478. byteLength?: number;
  67479. type?: string;
  67480. }
  67481. /** @hidden */
  67482. export interface IGLTFShader extends IGLTFChildRootProperty {
  67483. uri: string;
  67484. type: EShaderType;
  67485. }
  67486. /** @hidden */
  67487. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67488. attributes: string[];
  67489. fragmentShader: string;
  67490. vertexShader: string;
  67491. }
  67492. /** @hidden */
  67493. export interface IGLTFTechniqueParameter {
  67494. type: number;
  67495. count?: number;
  67496. semantic?: string;
  67497. node?: string;
  67498. value?: number | boolean | string | Array<any>;
  67499. source?: string;
  67500. babylonValue?: any;
  67501. }
  67502. /** @hidden */
  67503. export interface IGLTFTechniqueCommonProfile {
  67504. lightingModel: string;
  67505. texcoordBindings: Object;
  67506. parameters?: Array<any>;
  67507. }
  67508. /** @hidden */
  67509. export interface IGLTFTechniqueStatesFunctions {
  67510. blendColor?: number[];
  67511. blendEquationSeparate?: number[];
  67512. blendFuncSeparate?: number[];
  67513. colorMask: boolean[];
  67514. cullFace: number[];
  67515. }
  67516. /** @hidden */
  67517. export interface IGLTFTechniqueStates {
  67518. enable: number[];
  67519. functions: IGLTFTechniqueStatesFunctions;
  67520. }
  67521. /** @hidden */
  67522. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67523. parameters: {
  67524. [key: string]: IGLTFTechniqueParameter;
  67525. };
  67526. program: string;
  67527. attributes: {
  67528. [key: string]: string;
  67529. };
  67530. uniforms: {
  67531. [key: string]: string;
  67532. };
  67533. states: IGLTFTechniqueStates;
  67534. }
  67535. /** @hidden */
  67536. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67537. technique?: string;
  67538. values: string[];
  67539. }
  67540. /** @hidden */
  67541. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67542. attributes: {
  67543. [key: string]: string;
  67544. };
  67545. indices: string;
  67546. material: string;
  67547. mode?: number;
  67548. }
  67549. /** @hidden */
  67550. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67551. primitives: IGLTFMeshPrimitive[];
  67552. }
  67553. /** @hidden */
  67554. export interface IGLTFImage extends IGLTFChildRootProperty {
  67555. uri: string;
  67556. }
  67557. /** @hidden */
  67558. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67559. magFilter?: number;
  67560. minFilter?: number;
  67561. wrapS?: number;
  67562. wrapT?: number;
  67563. }
  67564. /** @hidden */
  67565. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67566. sampler: string;
  67567. source: string;
  67568. format?: ETextureFormat;
  67569. internalFormat?: ETextureFormat;
  67570. target?: number;
  67571. type?: number;
  67572. babylonTexture?: Texture;
  67573. }
  67574. /** @hidden */
  67575. export interface IGLTFAmbienLight {
  67576. color?: number[];
  67577. }
  67578. /** @hidden */
  67579. export interface IGLTFDirectionalLight {
  67580. color?: number[];
  67581. }
  67582. /** @hidden */
  67583. export interface IGLTFPointLight {
  67584. color?: number[];
  67585. constantAttenuation?: number;
  67586. linearAttenuation?: number;
  67587. quadraticAttenuation?: number;
  67588. }
  67589. /** @hidden */
  67590. export interface IGLTFSpotLight {
  67591. color?: number[];
  67592. constantAttenuation?: number;
  67593. fallOfAngle?: number;
  67594. fallOffExponent?: number;
  67595. linearAttenuation?: number;
  67596. quadraticAttenuation?: number;
  67597. }
  67598. /** @hidden */
  67599. export interface IGLTFLight extends IGLTFChildRootProperty {
  67600. type: string;
  67601. }
  67602. /** @hidden */
  67603. export interface IGLTFCameraOrthographic {
  67604. xmag: number;
  67605. ymag: number;
  67606. zfar: number;
  67607. znear: number;
  67608. }
  67609. /** @hidden */
  67610. export interface IGLTFCameraPerspective {
  67611. aspectRatio: number;
  67612. yfov: number;
  67613. zfar: number;
  67614. znear: number;
  67615. }
  67616. /** @hidden */
  67617. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67618. type: string;
  67619. }
  67620. /** @hidden */
  67621. export interface IGLTFAnimationChannelTarget {
  67622. id: string;
  67623. path: string;
  67624. }
  67625. /** @hidden */
  67626. export interface IGLTFAnimationChannel {
  67627. sampler: string;
  67628. target: IGLTFAnimationChannelTarget;
  67629. }
  67630. /** @hidden */
  67631. export interface IGLTFAnimationSampler {
  67632. input: string;
  67633. output: string;
  67634. interpolation?: string;
  67635. }
  67636. /** @hidden */
  67637. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67638. channels?: IGLTFAnimationChannel[];
  67639. parameters?: {
  67640. [key: string]: string;
  67641. };
  67642. samplers?: {
  67643. [key: string]: IGLTFAnimationSampler;
  67644. };
  67645. }
  67646. /** @hidden */
  67647. export interface IGLTFNodeInstanceSkin {
  67648. skeletons: string[];
  67649. skin: string;
  67650. meshes: string[];
  67651. }
  67652. /** @hidden */
  67653. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67654. bindShapeMatrix: number[];
  67655. inverseBindMatrices: string;
  67656. jointNames: string[];
  67657. babylonSkeleton?: Skeleton;
  67658. }
  67659. /** @hidden */
  67660. export interface IGLTFNode extends IGLTFChildRootProperty {
  67661. camera?: string;
  67662. children: string[];
  67663. skin?: string;
  67664. jointName?: string;
  67665. light?: string;
  67666. matrix: number[];
  67667. mesh?: string;
  67668. meshes?: string[];
  67669. rotation?: number[];
  67670. scale?: number[];
  67671. translation?: number[];
  67672. babylonNode?: Node;
  67673. }
  67674. /** @hidden */
  67675. export interface IGLTFScene extends IGLTFChildRootProperty {
  67676. nodes: string[];
  67677. }
  67678. /** @hidden */
  67679. export interface IGLTFRuntime {
  67680. extensions: {
  67681. [key: string]: any;
  67682. };
  67683. accessors: {
  67684. [key: string]: IGLTFAccessor;
  67685. };
  67686. buffers: {
  67687. [key: string]: IGLTFBuffer;
  67688. };
  67689. bufferViews: {
  67690. [key: string]: IGLTFBufferView;
  67691. };
  67692. meshes: {
  67693. [key: string]: IGLTFMesh;
  67694. };
  67695. lights: {
  67696. [key: string]: IGLTFLight;
  67697. };
  67698. cameras: {
  67699. [key: string]: IGLTFCamera;
  67700. };
  67701. nodes: {
  67702. [key: string]: IGLTFNode;
  67703. };
  67704. images: {
  67705. [key: string]: IGLTFImage;
  67706. };
  67707. textures: {
  67708. [key: string]: IGLTFTexture;
  67709. };
  67710. shaders: {
  67711. [key: string]: IGLTFShader;
  67712. };
  67713. programs: {
  67714. [key: string]: IGLTFProgram;
  67715. };
  67716. samplers: {
  67717. [key: string]: IGLTFSampler;
  67718. };
  67719. techniques: {
  67720. [key: string]: IGLTFTechnique;
  67721. };
  67722. materials: {
  67723. [key: string]: IGLTFMaterial;
  67724. };
  67725. animations: {
  67726. [key: string]: IGLTFAnimation;
  67727. };
  67728. skins: {
  67729. [key: string]: IGLTFSkins;
  67730. };
  67731. currentScene?: Object;
  67732. scenes: {
  67733. [key: string]: IGLTFScene;
  67734. };
  67735. extensionsUsed: string[];
  67736. extensionsRequired?: string[];
  67737. buffersCount: number;
  67738. shaderscount: number;
  67739. scene: Scene;
  67740. rootUrl: string;
  67741. loadedBufferCount: number;
  67742. loadedBufferViews: {
  67743. [name: string]: ArrayBufferView;
  67744. };
  67745. loadedShaderCount: number;
  67746. importOnlyMeshes: boolean;
  67747. importMeshesNames?: string[];
  67748. dummyNodes: Node[];
  67749. }
  67750. /** @hidden */
  67751. export interface INodeToRoot {
  67752. bone: Bone;
  67753. node: IGLTFNode;
  67754. id: string;
  67755. }
  67756. /** @hidden */
  67757. export interface IJointNode {
  67758. node: IGLTFNode;
  67759. id: string;
  67760. }
  67761. }
  67762. declare module BABYLON.GLTF1 {
  67763. /**
  67764. * Utils functions for GLTF
  67765. * @hidden
  67766. */
  67767. export class GLTFUtils {
  67768. /**
  67769. * Sets the given "parameter" matrix
  67770. * @param scene: the Scene object
  67771. * @param source: the source node where to pick the matrix
  67772. * @param parameter: the GLTF technique parameter
  67773. * @param uniformName: the name of the shader's uniform
  67774. * @param shaderMaterial: the shader material
  67775. */
  67776. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67777. /**
  67778. * Sets the given "parameter" matrix
  67779. * @param shaderMaterial: the shader material
  67780. * @param uniform: the name of the shader's uniform
  67781. * @param value: the value of the uniform
  67782. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67783. */
  67784. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67785. /**
  67786. * Returns the wrap mode of the texture
  67787. * @param mode: the mode value
  67788. */
  67789. static GetWrapMode(mode: number): number;
  67790. /**
  67791. * Returns the byte stride giving an accessor
  67792. * @param accessor: the GLTF accessor objet
  67793. */
  67794. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67795. /**
  67796. * Returns the texture filter mode giving a mode value
  67797. * @param mode: the filter mode value
  67798. */
  67799. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67800. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67801. /**
  67802. * Returns a buffer from its accessor
  67803. * @param gltfRuntime: the GLTF runtime
  67804. * @param accessor: the GLTF accessor
  67805. */
  67806. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67807. /**
  67808. * Decodes a buffer view into a string
  67809. * @param view: the buffer view
  67810. */
  67811. static DecodeBufferToText(view: ArrayBufferView): string;
  67812. /**
  67813. * Returns the default material of gltf. Related to
  67814. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67815. * @param scene: the Babylon.js scene
  67816. */
  67817. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67818. private static _DefaultMaterial;
  67819. }
  67820. }
  67821. declare module BABYLON.GLTF1 {
  67822. /**
  67823. * Implementation of the base glTF spec
  67824. * @hidden
  67825. */
  67826. export class GLTFLoaderBase {
  67827. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67828. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67829. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67830. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67831. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67832. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67833. }
  67834. /**
  67835. * glTF V1 Loader
  67836. * @hidden
  67837. */
  67838. export class GLTFLoader implements IGLTFLoader {
  67839. static Extensions: {
  67840. [name: string]: GLTFLoaderExtension;
  67841. };
  67842. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67843. state: Nullable<GLTFLoaderState>;
  67844. dispose(): void;
  67845. private _importMeshAsync;
  67846. /**
  67847. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67848. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67849. * @param scene the scene the meshes should be added to
  67850. * @param data gltf data containing information of the meshes in a loaded file
  67851. * @param rootUrl root url to load from
  67852. * @param onProgress event that fires when loading progress has occured
  67853. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67854. */
  67855. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67856. meshes: AbstractMesh[];
  67857. particleSystems: IParticleSystem[];
  67858. skeletons: Skeleton[];
  67859. animationGroups: AnimationGroup[];
  67860. }>;
  67861. private _loadAsync;
  67862. /**
  67863. * Imports all objects from a loaded gltf file and adds them to the scene
  67864. * @param scene the scene the objects should be added to
  67865. * @param data gltf data containing information of the meshes in a loaded file
  67866. * @param rootUrl root url to load from
  67867. * @param onProgress event that fires when loading progress has occured
  67868. * @returns a promise which completes when objects have been loaded to the scene
  67869. */
  67870. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67871. private _loadShadersAsync;
  67872. private _loadBuffersAsync;
  67873. private _createNodes;
  67874. }
  67875. /** @hidden */
  67876. export abstract class GLTFLoaderExtension {
  67877. private _name;
  67878. constructor(name: string);
  67879. readonly name: string;
  67880. /**
  67881. * Defines an override for loading the runtime
  67882. * Return true to stop further extensions from loading the runtime
  67883. */
  67884. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67885. /**
  67886. * Defines an onverride for creating gltf runtime
  67887. * Return true to stop further extensions from creating the runtime
  67888. */
  67889. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67890. /**
  67891. * Defines an override for loading buffers
  67892. * Return true to stop further extensions from loading this buffer
  67893. */
  67894. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67895. /**
  67896. * Defines an override for loading texture buffers
  67897. * Return true to stop further extensions from loading this texture data
  67898. */
  67899. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67900. /**
  67901. * Defines an override for creating textures
  67902. * Return true to stop further extensions from loading this texture
  67903. */
  67904. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67905. /**
  67906. * Defines an override for loading shader strings
  67907. * Return true to stop further extensions from loading this shader data
  67908. */
  67909. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67910. /**
  67911. * Defines an override for loading materials
  67912. * Return true to stop further extensions from loading this material
  67913. */
  67914. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67915. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67916. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67917. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67918. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67919. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67920. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67921. private static LoadTextureBufferAsync;
  67922. private static CreateTextureAsync;
  67923. private static ApplyExtensions;
  67924. }
  67925. }
  67926. declare module BABYLON.GLTF1 {
  67927. /** @hidden */
  67928. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67929. private _bin;
  67930. constructor();
  67931. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67932. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67933. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67934. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67935. }
  67936. }
  67937. declare module BABYLON.GLTF1 {
  67938. /** @hidden */
  67939. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67940. constructor();
  67941. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67942. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67943. private _loadTexture;
  67944. }
  67945. }
  67946. declare module BABYLON.GLTF2.Loader {
  67947. /**
  67948. * Loader interface with an index field.
  67949. */
  67950. export interface IArrayItem {
  67951. /**
  67952. * The index of this item in the array.
  67953. */
  67954. index: number;
  67955. }
  67956. /**
  67957. * Loader interface with additional members.
  67958. */
  67959. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67960. /** @hidden */
  67961. _data?: Promise<ArrayBufferView>;
  67962. /** @hidden */
  67963. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67964. }
  67965. /**
  67966. * Loader interface with additional members.
  67967. */
  67968. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67969. }
  67970. /** @hidden */
  67971. export interface _IAnimationSamplerData {
  67972. input: Float32Array;
  67973. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67974. output: Float32Array;
  67975. }
  67976. /**
  67977. * Loader interface with additional members.
  67978. */
  67979. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67980. /** @hidden */
  67981. _data?: Promise<_IAnimationSamplerData>;
  67982. }
  67983. /**
  67984. * Loader interface with additional members.
  67985. */
  67986. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67987. channels: IAnimationChannel[];
  67988. samplers: IAnimationSampler[];
  67989. /** @hidden */
  67990. _babylonAnimationGroup?: AnimationGroup;
  67991. }
  67992. /**
  67993. * Loader interface with additional members.
  67994. */
  67995. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67996. /** @hidden */
  67997. _data?: Promise<ArrayBufferView>;
  67998. }
  67999. /**
  68000. * Loader interface with additional members.
  68001. */
  68002. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68003. /** @hidden */
  68004. _data?: Promise<ArrayBufferView>;
  68005. /** @hidden */
  68006. _babylonBuffer?: Promise<Buffer>;
  68007. }
  68008. /**
  68009. * Loader interface with additional members.
  68010. */
  68011. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68012. }
  68013. /**
  68014. * Loader interface with additional members.
  68015. */
  68016. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68017. /** @hidden */
  68018. _data?: Promise<ArrayBufferView>;
  68019. }
  68020. /**
  68021. * Loader interface with additional members.
  68022. */
  68023. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68024. }
  68025. /**
  68026. * Loader interface with additional members.
  68027. */
  68028. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68029. }
  68030. /**
  68031. * Loader interface with additional members.
  68032. */
  68033. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68034. baseColorTexture?: ITextureInfo;
  68035. metallicRoughnessTexture?: ITextureInfo;
  68036. }
  68037. /**
  68038. * Loader interface with additional members.
  68039. */
  68040. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68041. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68042. normalTexture?: IMaterialNormalTextureInfo;
  68043. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68044. emissiveTexture?: ITextureInfo;
  68045. /** @hidden */
  68046. _data?: {
  68047. [babylonDrawMode: number]: {
  68048. babylonMaterial: Material;
  68049. babylonMeshes: AbstractMesh[];
  68050. promise: Promise<void>;
  68051. };
  68052. };
  68053. }
  68054. /**
  68055. * Loader interface with additional members.
  68056. */
  68057. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68058. primitives: IMeshPrimitive[];
  68059. }
  68060. /**
  68061. * Loader interface with additional members.
  68062. */
  68063. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68064. /** @hidden */
  68065. _instanceData?: {
  68066. babylonSourceMesh: Mesh;
  68067. promise: Promise<any>;
  68068. };
  68069. }
  68070. /**
  68071. * Loader interface with additional members.
  68072. */
  68073. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68074. /**
  68075. * The parent glTF node.
  68076. */
  68077. parent?: INode;
  68078. /** @hidden */
  68079. _babylonTransformNode?: TransformNode;
  68080. /** @hidden */
  68081. _primitiveBabylonMeshes?: AbstractMesh[];
  68082. /** @hidden */
  68083. _babylonBones?: Bone[];
  68084. /** @hidden */
  68085. _numMorphTargets?: number;
  68086. }
  68087. /** @hidden */
  68088. export interface _ISamplerData {
  68089. noMipMaps: boolean;
  68090. samplingMode: number;
  68091. wrapU: number;
  68092. wrapV: number;
  68093. }
  68094. /**
  68095. * Loader interface with additional members.
  68096. */
  68097. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68098. /** @hidden */
  68099. _data?: _ISamplerData;
  68100. }
  68101. /**
  68102. * Loader interface with additional members.
  68103. */
  68104. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68105. }
  68106. /**
  68107. * Loader interface with additional members.
  68108. */
  68109. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68110. /** @hidden */
  68111. _data?: {
  68112. babylonSkeleton: Skeleton;
  68113. promise: Promise<void>;
  68114. };
  68115. }
  68116. /**
  68117. * Loader interface with additional members.
  68118. */
  68119. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68120. }
  68121. /**
  68122. * Loader interface with additional members.
  68123. */
  68124. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68125. }
  68126. /**
  68127. * Loader interface with additional members.
  68128. */
  68129. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68130. accessors?: IAccessor[];
  68131. animations?: IAnimation[];
  68132. buffers?: IBuffer[];
  68133. bufferViews?: IBufferView[];
  68134. cameras?: ICamera[];
  68135. images?: IImage[];
  68136. materials?: IMaterial[];
  68137. meshes?: IMesh[];
  68138. nodes?: INode[];
  68139. samplers?: ISampler[];
  68140. scenes?: IScene[];
  68141. skins?: ISkin[];
  68142. textures?: ITexture[];
  68143. }
  68144. }
  68145. declare module BABYLON.GLTF2 {
  68146. /**
  68147. * Interface for a glTF loader extension.
  68148. */
  68149. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68150. /**
  68151. * Called after the loader state changes to LOADING.
  68152. */
  68153. onLoading?(): void;
  68154. /**
  68155. * Called after the loader state changes to READY.
  68156. */
  68157. onReady?(): void;
  68158. /**
  68159. * Define this method to modify the default behavior when loading scenes.
  68160. * @param context The context when loading the asset
  68161. * @param scene The glTF scene property
  68162. * @returns A promise that resolves when the load is complete or null if not handled
  68163. */
  68164. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68165. /**
  68166. * Define this method to modify the default behavior when loading nodes.
  68167. * @param context The context when loading the asset
  68168. * @param node The glTF node property
  68169. * @param assign A function called synchronously after parsing the glTF properties
  68170. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68171. */
  68172. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68173. /**
  68174. * Define this method to modify the default behavior when loading cameras.
  68175. * @param context The context when loading the asset
  68176. * @param camera The glTF camera property
  68177. * @param assign A function called synchronously after parsing the glTF properties
  68178. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68179. */
  68180. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68181. /**
  68182. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68183. * @param context The context when loading the asset
  68184. * @param primitive The glTF mesh primitive property
  68185. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68186. */
  68187. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68188. /**
  68189. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68190. * @param context The context when loading the asset
  68191. * @param name The mesh name when loading the asset
  68192. * @param node The glTF node when loading the asset
  68193. * @param mesh The glTF mesh when loading the asset
  68194. * @param primitive The glTF mesh primitive property
  68195. * @param assign A function called synchronously after parsing the glTF properties
  68196. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68197. */
  68198. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68199. /**
  68200. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68201. * @param context The context when loading the asset
  68202. * @param material The glTF material property
  68203. * @param assign A function called synchronously after parsing the glTF properties
  68204. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68205. */
  68206. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68207. /**
  68208. * Define this method to modify the default behavior when creating materials.
  68209. * @param context The context when loading the asset
  68210. * @param material The glTF material property
  68211. * @param babylonDrawMode The draw mode for the Babylon material
  68212. * @returns The Babylon material or null if not handled
  68213. */
  68214. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68215. /**
  68216. * Define this method to modify the default behavior when loading material properties.
  68217. * @param context The context when loading the asset
  68218. * @param material The glTF material property
  68219. * @param babylonMaterial The Babylon material
  68220. * @returns A promise that resolves when the load is complete or null if not handled
  68221. */
  68222. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68223. /**
  68224. * Define this method to modify the default behavior when loading texture infos.
  68225. * @param context The context when loading the asset
  68226. * @param textureInfo The glTF texture info property
  68227. * @param assign A function called synchronously after parsing the glTF properties
  68228. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68229. */
  68230. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68231. /**
  68232. * Define this method to modify the default behavior when loading animations.
  68233. * @param context The context when loading the asset
  68234. * @param animation The glTF animation property
  68235. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68236. */
  68237. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68238. /**
  68239. * @hidden Define this method to modify the default behavior when loading skins.
  68240. * @param context The context when loading the asset
  68241. * @param node The glTF node property
  68242. * @param skin The glTF skin property
  68243. * @returns A promise that resolves when the load is complete or null if not handled
  68244. */
  68245. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68246. /**
  68247. * @hidden Define this method to modify the default behavior when loading uris.
  68248. * @param context The context when loading the asset
  68249. * @param property The glTF property associated with the uri
  68250. * @param uri The uri to load
  68251. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68252. */
  68253. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68254. }
  68255. }
  68256. declare module BABYLON.GLTF2 {
  68257. /**
  68258. * Helper class for working with arrays when loading the glTF asset
  68259. */
  68260. export class ArrayItem {
  68261. /**
  68262. * Gets an item from the given array.
  68263. * @param context The context when loading the asset
  68264. * @param array The array to get the item from
  68265. * @param index The index to the array
  68266. * @returns The array item
  68267. */
  68268. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68269. /**
  68270. * Assign an `index` field to each item of the given array.
  68271. * @param array The array of items
  68272. */
  68273. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68274. }
  68275. /**
  68276. * The glTF 2.0 loader
  68277. */
  68278. export class GLTFLoader implements IGLTFLoader {
  68279. /** @hidden */
  68280. _completePromises: Promise<any>[];
  68281. private _disposed;
  68282. private _parent;
  68283. private _state;
  68284. private _extensions;
  68285. private _rootUrl;
  68286. private _fileName;
  68287. private _uniqueRootUrl;
  68288. private _gltf;
  68289. private _babylonScene;
  68290. private _rootBabylonMesh;
  68291. private _defaultBabylonMaterialData;
  68292. private _progressCallback?;
  68293. private _requests;
  68294. private static readonly _DefaultSampler;
  68295. private static _ExtensionNames;
  68296. private static _ExtensionFactories;
  68297. /**
  68298. * Registers a loader extension.
  68299. * @param name The name of the loader extension.
  68300. * @param factory The factory function that creates the loader extension.
  68301. */
  68302. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68303. /**
  68304. * Unregisters a loader extension.
  68305. * @param name The name of the loader extenion.
  68306. * @returns A boolean indicating whether the extension has been unregistered
  68307. */
  68308. static UnregisterExtension(name: string): boolean;
  68309. /**
  68310. * Gets the loader state.
  68311. */
  68312. readonly state: Nullable<GLTFLoaderState>;
  68313. /**
  68314. * The glTF object parsed from the JSON.
  68315. */
  68316. readonly gltf: IGLTF;
  68317. /**
  68318. * The Babylon scene when loading the asset.
  68319. */
  68320. readonly babylonScene: Scene;
  68321. /**
  68322. * The root Babylon mesh when loading the asset.
  68323. */
  68324. readonly rootBabylonMesh: Mesh;
  68325. /** @hidden */
  68326. constructor(parent: GLTFFileLoader);
  68327. /** @hidden */
  68328. dispose(): void;
  68329. /** @hidden */
  68330. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68331. meshes: AbstractMesh[];
  68332. particleSystems: IParticleSystem[];
  68333. skeletons: Skeleton[];
  68334. animationGroups: AnimationGroup[];
  68335. }>;
  68336. /** @hidden */
  68337. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68338. private _loadAsync;
  68339. private _loadData;
  68340. private _setupData;
  68341. private _loadExtensions;
  68342. private _checkExtensions;
  68343. private _setState;
  68344. private _createRootNode;
  68345. /**
  68346. * Loads a glTF scene.
  68347. * @param context The context when loading the asset
  68348. * @param scene The glTF scene property
  68349. * @returns A promise that resolves when the load is complete
  68350. */
  68351. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68352. private _forEachPrimitive;
  68353. private _getMeshes;
  68354. private _getSkeletons;
  68355. private _getAnimationGroups;
  68356. private _startAnimations;
  68357. /**
  68358. * Loads a glTF node.
  68359. * @param context The context when loading the asset
  68360. * @param node The glTF node property
  68361. * @param assign A function called synchronously after parsing the glTF properties
  68362. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68363. */
  68364. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68365. private _loadMeshAsync;
  68366. /**
  68367. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68368. * @param context The context when loading the asset
  68369. * @param name The mesh name when loading the asset
  68370. * @param node The glTF node when loading the asset
  68371. * @param mesh The glTF mesh when loading the asset
  68372. * @param primitive The glTF mesh primitive property
  68373. * @param assign A function called synchronously after parsing the glTF properties
  68374. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68375. */
  68376. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68377. private _loadVertexDataAsync;
  68378. private _createMorphTargets;
  68379. private _loadMorphTargetsAsync;
  68380. private _loadMorphTargetVertexDataAsync;
  68381. private static _LoadTransform;
  68382. private _loadSkinAsync;
  68383. private _loadBones;
  68384. private _loadBone;
  68385. private _loadSkinInverseBindMatricesDataAsync;
  68386. private _updateBoneMatrices;
  68387. private _getNodeMatrix;
  68388. /**
  68389. * Loads a glTF camera.
  68390. * @param context The context when loading the asset
  68391. * @param camera The glTF camera property
  68392. * @param assign A function called synchronously after parsing the glTF properties
  68393. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68394. */
  68395. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68396. private _loadAnimationsAsync;
  68397. /**
  68398. * Loads a glTF animation.
  68399. * @param context The context when loading the asset
  68400. * @param animation The glTF animation property
  68401. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68402. */
  68403. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68404. /**
  68405. * @hidden Loads a glTF animation channel.
  68406. * @param context The context when loading the asset
  68407. * @param animationContext The context of the animation when loading the asset
  68408. * @param animation The glTF animation property
  68409. * @param channel The glTF animation channel property
  68410. * @param babylonAnimationGroup The babylon animation group property
  68411. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68412. * @returns A void promise when the channel load is complete
  68413. */
  68414. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68415. private _loadAnimationSamplerAsync;
  68416. private _loadBufferAsync;
  68417. /**
  68418. * Loads a glTF buffer view.
  68419. * @param context The context when loading the asset
  68420. * @param bufferView The glTF buffer view property
  68421. * @returns A promise that resolves with the loaded data when the load is complete
  68422. */
  68423. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68424. private _loadAccessorAsync;
  68425. private _loadFloatAccessorAsync;
  68426. private _loadIndicesAccessorAsync;
  68427. private _loadVertexBufferViewAsync;
  68428. private _loadVertexAccessorAsync;
  68429. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68430. /** @hidden */
  68431. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68432. private _createDefaultMaterial;
  68433. /**
  68434. * Creates a Babylon material from a glTF material.
  68435. * @param context The context when loading the asset
  68436. * @param material The glTF material property
  68437. * @param babylonDrawMode The draw mode for the Babylon material
  68438. * @returns The Babylon material
  68439. */
  68440. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68441. /**
  68442. * Loads properties from a glTF material into a Babylon material.
  68443. * @param context The context when loading the asset
  68444. * @param material The glTF material property
  68445. * @param babylonMaterial The Babylon material
  68446. * @returns A promise that resolves when the load is complete
  68447. */
  68448. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68449. /**
  68450. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68451. * @param context The context when loading the asset
  68452. * @param material The glTF material property
  68453. * @param babylonMaterial The Babylon material
  68454. * @returns A promise that resolves when the load is complete
  68455. */
  68456. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68457. /**
  68458. * Loads the alpha properties from a glTF material into a Babylon material.
  68459. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68460. * @param context The context when loading the asset
  68461. * @param material The glTF material property
  68462. * @param babylonMaterial The Babylon material
  68463. */
  68464. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68465. /**
  68466. * Loads a glTF texture info.
  68467. * @param context The context when loading the asset
  68468. * @param textureInfo The glTF texture info property
  68469. * @param assign A function called synchronously after parsing the glTF properties
  68470. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68471. */
  68472. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68473. private _loadTextureAsync;
  68474. private _loadSampler;
  68475. /**
  68476. * Loads a glTF image.
  68477. * @param context The context when loading the asset
  68478. * @param image The glTF image property
  68479. * @returns A promise that resolves with the loaded data when the load is complete
  68480. */
  68481. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68482. /**
  68483. * Loads a glTF uri.
  68484. * @param context The context when loading the asset
  68485. * @param property The glTF property associated with the uri
  68486. * @param uri The base64 or relative uri
  68487. * @returns A promise that resolves with the loaded data when the load is complete
  68488. */
  68489. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68490. private _onProgress;
  68491. /**
  68492. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68493. * @param babylonObject the Babylon object with metadata
  68494. * @param pointer the JSON pointer
  68495. */
  68496. static AddPointerMetadata(babylonObject: {
  68497. metadata: any;
  68498. }, pointer: string): void;
  68499. private static _GetTextureWrapMode;
  68500. private static _GetTextureSamplingMode;
  68501. private static _GetTypedArrayConstructor;
  68502. private static _GetTypedArray;
  68503. private static _GetNumComponents;
  68504. private static _ValidateUri;
  68505. private static _GetDrawMode;
  68506. private _compileMaterialsAsync;
  68507. private _compileShadowGeneratorsAsync;
  68508. private _forEachExtensions;
  68509. private _applyExtensions;
  68510. private _extensionsOnLoading;
  68511. private _extensionsOnReady;
  68512. private _extensionsLoadSceneAsync;
  68513. private _extensionsLoadNodeAsync;
  68514. private _extensionsLoadCameraAsync;
  68515. private _extensionsLoadVertexDataAsync;
  68516. private _extensionsLoadMeshPrimitiveAsync;
  68517. private _extensionsLoadMaterialAsync;
  68518. private _extensionsCreateMaterial;
  68519. private _extensionsLoadMaterialPropertiesAsync;
  68520. private _extensionsLoadTextureInfoAsync;
  68521. private _extensionsLoadAnimationAsync;
  68522. private _extensionsLoadSkinAsync;
  68523. private _extensionsLoadUriAsync;
  68524. /**
  68525. * Helper method called by a loader extension to load an glTF extension.
  68526. * @param context The context when loading the asset
  68527. * @param property The glTF property to load the extension from
  68528. * @param extensionName The name of the extension to load
  68529. * @param actionAsync The action to run
  68530. * @returns The promise returned by actionAsync or null if the extension does not exist
  68531. */
  68532. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68533. /**
  68534. * Helper method called by a loader extension to load a glTF extra.
  68535. * @param context The context when loading the asset
  68536. * @param property The glTF property to load the extra from
  68537. * @param extensionName The name of the extension to load
  68538. * @param actionAsync The action to run
  68539. * @returns The promise returned by actionAsync or null if the extra does not exist
  68540. */
  68541. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68542. /**
  68543. * Increments the indentation level and logs a message.
  68544. * @param message The message to log
  68545. */
  68546. logOpen(message: string): void;
  68547. /**
  68548. * Decrements the indentation level.
  68549. */
  68550. logClose(): void;
  68551. /**
  68552. * Logs a message
  68553. * @param message The message to log
  68554. */
  68555. log(message: string): void;
  68556. /**
  68557. * Starts a performance counter.
  68558. * @param counterName The name of the performance counter
  68559. */
  68560. startPerformanceCounter(counterName: string): void;
  68561. /**
  68562. * Ends a performance counter.
  68563. * @param counterName The name of the performance counter
  68564. */
  68565. endPerformanceCounter(counterName: string): void;
  68566. }
  68567. }
  68568. declare module BABYLON.GLTF2.Loader.Extensions {
  68569. /**
  68570. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68571. */
  68572. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68573. /** The name of this extension. */
  68574. readonly name: string;
  68575. /** Defines whether this extension is enabled. */
  68576. enabled: boolean;
  68577. private _loader;
  68578. private _lights?;
  68579. /** @hidden */
  68580. constructor(loader: GLTFLoader);
  68581. /** @hidden */
  68582. dispose(): void;
  68583. /** @hidden */
  68584. onLoading(): void;
  68585. /** @hidden */
  68586. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68587. private _loadLightAsync;
  68588. }
  68589. }
  68590. declare module BABYLON.GLTF2.Loader.Extensions {
  68591. /**
  68592. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68593. */
  68594. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68595. /** The name of this extension. */
  68596. readonly name: string;
  68597. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68598. dracoCompression?: DracoCompression;
  68599. /** Defines whether this extension is enabled. */
  68600. enabled: boolean;
  68601. private _loader;
  68602. /** @hidden */
  68603. constructor(loader: GLTFLoader);
  68604. /** @hidden */
  68605. dispose(): void;
  68606. /** @hidden */
  68607. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68608. }
  68609. }
  68610. declare module BABYLON.GLTF2.Loader.Extensions {
  68611. /**
  68612. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68613. */
  68614. export class KHR_lights implements IGLTFLoaderExtension {
  68615. /** The name of this extension. */
  68616. readonly name: string;
  68617. /** Defines whether this extension is enabled. */
  68618. enabled: boolean;
  68619. private _loader;
  68620. private _lights?;
  68621. /** @hidden */
  68622. constructor(loader: GLTFLoader);
  68623. /** @hidden */
  68624. dispose(): void;
  68625. /** @hidden */
  68626. onLoading(): void;
  68627. /** @hidden */
  68628. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68629. }
  68630. }
  68631. declare module BABYLON.GLTF2.Loader.Extensions {
  68632. /**
  68633. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68634. */
  68635. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68636. /** The name of this extension. */
  68637. readonly name: string;
  68638. /** Defines whether this extension is enabled. */
  68639. enabled: boolean;
  68640. private _loader;
  68641. /** @hidden */
  68642. constructor(loader: GLTFLoader);
  68643. /** @hidden */
  68644. dispose(): void;
  68645. /** @hidden */
  68646. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68647. private _loadSpecularGlossinessPropertiesAsync;
  68648. }
  68649. }
  68650. declare module BABYLON.GLTF2.Loader.Extensions {
  68651. /**
  68652. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68653. */
  68654. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68655. /** The name of this extension. */
  68656. readonly name: string;
  68657. /** Defines whether this extension is enabled. */
  68658. enabled: boolean;
  68659. private _loader;
  68660. /** @hidden */
  68661. constructor(loader: GLTFLoader);
  68662. /** @hidden */
  68663. dispose(): void;
  68664. /** @hidden */
  68665. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68666. private _loadUnlitPropertiesAsync;
  68667. }
  68668. }
  68669. declare module BABYLON.GLTF2.Loader.Extensions {
  68670. /**
  68671. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68672. */
  68673. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68674. /** The name of this extension. */
  68675. readonly name: string;
  68676. /** Defines whether this extension is enabled. */
  68677. enabled: boolean;
  68678. private _loader;
  68679. /** @hidden */
  68680. constructor(loader: GLTFLoader);
  68681. /** @hidden */
  68682. dispose(): void;
  68683. /** @hidden */
  68684. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68685. }
  68686. }
  68687. declare module BABYLON.GLTF2.Loader.Extensions {
  68688. /**
  68689. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68690. */
  68691. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68692. /** The name of this extension. */
  68693. readonly name: string;
  68694. /** Defines whether this extension is enabled. */
  68695. enabled: boolean;
  68696. private _loader;
  68697. private _clips;
  68698. private _emitters;
  68699. /** @hidden */
  68700. constructor(loader: GLTFLoader);
  68701. /** @hidden */
  68702. dispose(): void;
  68703. /** @hidden */
  68704. onLoading(): void;
  68705. /** @hidden */
  68706. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68707. /** @hidden */
  68708. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68709. /** @hidden */
  68710. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68711. private _loadClipAsync;
  68712. private _loadEmitterAsync;
  68713. private _getEventAction;
  68714. private _loadAnimationEventAsync;
  68715. }
  68716. }
  68717. declare module BABYLON.GLTF2.Loader.Extensions {
  68718. /**
  68719. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68720. */
  68721. export class MSFT_lod implements IGLTFLoaderExtension {
  68722. /** The name of this extension. */
  68723. readonly name: string;
  68724. /** Defines whether this extension is enabled. */
  68725. enabled: boolean;
  68726. /**
  68727. * Maximum number of LODs to load, starting from the lowest LOD.
  68728. */
  68729. maxLODsToLoad: number;
  68730. /**
  68731. * Observable raised when all node LODs of one level are loaded.
  68732. * The event data is the index of the loaded LOD starting from zero.
  68733. * Dispose the loader to cancel the loading of the next level of LODs.
  68734. */
  68735. onNodeLODsLoadedObservable: Observable<number>;
  68736. /**
  68737. * Observable raised when all material LODs of one level are loaded.
  68738. * The event data is the index of the loaded LOD starting from zero.
  68739. * Dispose the loader to cancel the loading of the next level of LODs.
  68740. */
  68741. onMaterialLODsLoadedObservable: Observable<number>;
  68742. private _loader;
  68743. private _nodeIndexLOD;
  68744. private _nodeSignalLODs;
  68745. private _nodePromiseLODs;
  68746. private _materialIndexLOD;
  68747. private _materialSignalLODs;
  68748. private _materialPromiseLODs;
  68749. /** @hidden */
  68750. constructor(loader: GLTFLoader);
  68751. /** @hidden */
  68752. dispose(): void;
  68753. /** @hidden */
  68754. onReady(): void;
  68755. /** @hidden */
  68756. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68757. /** @hidden */
  68758. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68759. /** @hidden */
  68760. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68761. /**
  68762. * Gets an array of LOD properties from lowest to highest.
  68763. */
  68764. private _getLODs;
  68765. private _disposeUnusedMaterials;
  68766. }
  68767. }
  68768. declare module BABYLON.GLTF2.Loader.Extensions {
  68769. /** @hidden */
  68770. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68771. readonly name: string;
  68772. enabled: boolean;
  68773. private _loader;
  68774. constructor(loader: GLTFLoader);
  68775. dispose(): void;
  68776. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68777. }
  68778. }
  68779. declare module BABYLON.GLTF2.Loader.Extensions {
  68780. /** @hidden */
  68781. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68782. readonly name: string;
  68783. enabled: boolean;
  68784. private _loader;
  68785. constructor(loader: GLTFLoader);
  68786. dispose(): void;
  68787. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68788. }
  68789. }
  68790. declare module BABYLON.GLTF2.Loader.Extensions {
  68791. /**
  68792. * Store glTF extras (if present) in BJS objects' metadata
  68793. */
  68794. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68795. /** The name of this extension. */
  68796. readonly name: string;
  68797. /** Defines whether this extension is enabled. */
  68798. enabled: boolean;
  68799. private _loader;
  68800. private _assignExtras;
  68801. /** @hidden */
  68802. constructor(loader: GLTFLoader);
  68803. /** @hidden */
  68804. dispose(): void;
  68805. /** @hidden */
  68806. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68807. /** @hidden */
  68808. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68809. /** @hidden */
  68810. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68811. }
  68812. }
  68813. declare module BABYLON {
  68814. /**
  68815. * Class reading and parsing the MTL file bundled with the obj file.
  68816. */
  68817. export class MTLFileLoader {
  68818. /**
  68819. * All material loaded from the mtl will be set here
  68820. */
  68821. materials: StandardMaterial[];
  68822. /**
  68823. * This function will read the mtl file and create each material described inside
  68824. * This function could be improve by adding :
  68825. * -some component missing (Ni, Tf...)
  68826. * -including the specific options available
  68827. *
  68828. * @param scene defines the scene the material will be created in
  68829. * @param data defines the mtl data to parse
  68830. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68831. */
  68832. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68833. /**
  68834. * Gets the texture for the material.
  68835. *
  68836. * If the material is imported from input file,
  68837. * We sanitize the url to ensure it takes the textre from aside the material.
  68838. *
  68839. * @param rootUrl The root url to load from
  68840. * @param value The value stored in the mtl
  68841. * @return The Texture
  68842. */
  68843. private static _getTexture;
  68844. }
  68845. /**
  68846. * Options for loading OBJ/MTL files
  68847. */
  68848. type MeshLoadOptions = {
  68849. /**
  68850. * Defines if UVs are optimized by default during load.
  68851. */
  68852. OptimizeWithUV: boolean;
  68853. /**
  68854. * Defines custom scaling of UV coordinates of loaded meshes.
  68855. */
  68856. UVScaling: Vector2;
  68857. /**
  68858. * Invert model on y-axis (does a model scaling inversion)
  68859. */
  68860. InvertY: boolean;
  68861. /**
  68862. * Invert Y-Axis of referenced textures on load
  68863. */
  68864. InvertTextureY: boolean;
  68865. /**
  68866. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68867. */
  68868. ImportVertexColors: boolean;
  68869. /**
  68870. * Compute the normals for the model, even if normals are present in the file.
  68871. */
  68872. ComputeNormals: boolean;
  68873. /**
  68874. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68875. */
  68876. SkipMaterials: boolean;
  68877. /**
  68878. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68879. */
  68880. MaterialLoadingFailsSilently: boolean;
  68881. };
  68882. /**
  68883. * OBJ file type loader.
  68884. * This is a babylon scene loader plugin.
  68885. */
  68886. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68887. /**
  68888. * Defines if UVs are optimized by default during load.
  68889. */
  68890. static OPTIMIZE_WITH_UV: boolean;
  68891. /**
  68892. * Invert model on y-axis (does a model scaling inversion)
  68893. */
  68894. static INVERT_Y: boolean;
  68895. /**
  68896. * Invert Y-Axis of referenced textures on load
  68897. */
  68898. static INVERT_TEXTURE_Y: boolean;
  68899. /**
  68900. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68901. */
  68902. static IMPORT_VERTEX_COLORS: boolean;
  68903. /**
  68904. * Compute the normals for the model, even if normals are present in the file.
  68905. */
  68906. static COMPUTE_NORMALS: boolean;
  68907. /**
  68908. * Defines custom scaling of UV coordinates of loaded meshes.
  68909. */
  68910. static UV_SCALING: Vector2;
  68911. /**
  68912. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68913. */
  68914. static SKIP_MATERIALS: boolean;
  68915. /**
  68916. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68917. *
  68918. * Defaults to true for backwards compatibility.
  68919. */
  68920. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68921. /**
  68922. * Defines the name of the plugin.
  68923. */
  68924. name: string;
  68925. /**
  68926. * Defines the extension the plugin is able to load.
  68927. */
  68928. extensions: string;
  68929. /** @hidden */
  68930. obj: RegExp;
  68931. /** @hidden */
  68932. group: RegExp;
  68933. /** @hidden */
  68934. mtllib: RegExp;
  68935. /** @hidden */
  68936. usemtl: RegExp;
  68937. /** @hidden */
  68938. smooth: RegExp;
  68939. /** @hidden */
  68940. vertexPattern: RegExp;
  68941. /** @hidden */
  68942. normalPattern: RegExp;
  68943. /** @hidden */
  68944. uvPattern: RegExp;
  68945. /** @hidden */
  68946. facePattern1: RegExp;
  68947. /** @hidden */
  68948. facePattern2: RegExp;
  68949. /** @hidden */
  68950. facePattern3: RegExp;
  68951. /** @hidden */
  68952. facePattern4: RegExp;
  68953. /** @hidden */
  68954. facePattern5: RegExp;
  68955. private _meshLoadOptions;
  68956. /**
  68957. * Creates loader for .OBJ files
  68958. *
  68959. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68960. */
  68961. constructor(meshLoadOptions?: MeshLoadOptions);
  68962. private static readonly currentMeshLoadOptions;
  68963. /**
  68964. * Calls synchronously the MTL file attached to this obj.
  68965. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68966. * Without this function materials are not displayed in the first frame (but displayed after).
  68967. * In consequence it is impossible to get material information in your HTML file
  68968. *
  68969. * @param url The URL of the MTL file
  68970. * @param rootUrl
  68971. * @param onSuccess Callback function to be called when the MTL file is loaded
  68972. * @private
  68973. */
  68974. private _loadMTL;
  68975. /**
  68976. * Instantiates a OBJ file loader plugin.
  68977. * @returns the created plugin
  68978. */
  68979. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68980. /**
  68981. * If the data string can be loaded directly.
  68982. *
  68983. * @param data string containing the file data
  68984. * @returns if the data can be loaded directly
  68985. */
  68986. canDirectLoad(data: string): boolean;
  68987. /**
  68988. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68989. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68990. * @param scene the scene the meshes should be added to
  68991. * @param data the OBJ data to load
  68992. * @param rootUrl root url to load from
  68993. * @param onProgress event that fires when loading progress has occured
  68994. * @param fileName Defines the name of the file to load
  68995. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68996. */
  68997. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68998. meshes: AbstractMesh[];
  68999. particleSystems: IParticleSystem[];
  69000. skeletons: Skeleton[];
  69001. animationGroups: AnimationGroup[];
  69002. }>;
  69003. /**
  69004. * Imports all objects from the loaded OBJ data and adds them to the scene
  69005. * @param scene the scene the objects should be added to
  69006. * @param data the OBJ data to load
  69007. * @param rootUrl root url to load from
  69008. * @param onProgress event that fires when loading progress has occured
  69009. * @param fileName Defines the name of the file to load
  69010. * @returns a promise which completes when objects have been loaded to the scene
  69011. */
  69012. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69013. /**
  69014. * Load into an asset container.
  69015. * @param scene The scene to load into
  69016. * @param data The data to import
  69017. * @param rootUrl The root url for scene and resources
  69018. * @param onProgress The callback when the load progresses
  69019. * @param fileName Defines the name of the file to load
  69020. * @returns The loaded asset container
  69021. */
  69022. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69023. /**
  69024. * Read the OBJ file and create an Array of meshes.
  69025. * Each mesh contains all information given by the OBJ and the MTL file.
  69026. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69027. *
  69028. * @param meshesNames
  69029. * @param scene Scene The scene where are displayed the data
  69030. * @param data String The content of the obj file
  69031. * @param rootUrl String The path to the folder
  69032. * @returns Array<AbstractMesh>
  69033. * @private
  69034. */
  69035. private _parseSolid;
  69036. }
  69037. }
  69038. declare module BABYLON {
  69039. /**
  69040. * STL file type loader.
  69041. * This is a babylon scene loader plugin.
  69042. */
  69043. export class STLFileLoader implements ISceneLoaderPlugin {
  69044. /** @hidden */
  69045. solidPattern: RegExp;
  69046. /** @hidden */
  69047. facetsPattern: RegExp;
  69048. /** @hidden */
  69049. normalPattern: RegExp;
  69050. /** @hidden */
  69051. vertexPattern: RegExp;
  69052. /**
  69053. * Defines the name of the plugin.
  69054. */
  69055. name: string;
  69056. /**
  69057. * Defines the extensions the stl loader is able to load.
  69058. * force data to come in as an ArrayBuffer
  69059. * we'll convert to string if it looks like it's an ASCII .stl
  69060. */
  69061. extensions: ISceneLoaderPluginExtensions;
  69062. /**
  69063. * Import meshes into a scene.
  69064. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69065. * @param scene The scene to import into
  69066. * @param data The data to import
  69067. * @param rootUrl The root url for scene and resources
  69068. * @param meshes The meshes array to import into
  69069. * @param particleSystems The particle systems array to import into
  69070. * @param skeletons The skeletons array to import into
  69071. * @param onError The callback when import fails
  69072. * @returns True if successful or false otherwise
  69073. */
  69074. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69075. /**
  69076. * Load into a scene.
  69077. * @param scene The scene to load into
  69078. * @param data The data to import
  69079. * @param rootUrl The root url for scene and resources
  69080. * @param onError The callback when import fails
  69081. * @returns true if successful or false otherwise
  69082. */
  69083. load(scene: Scene, data: any, rootUrl: string): boolean;
  69084. /**
  69085. * Load into an asset container.
  69086. * @param scene The scene to load into
  69087. * @param data The data to import
  69088. * @param rootUrl The root url for scene and resources
  69089. * @param onError The callback when import fails
  69090. * @returns The loaded asset container
  69091. */
  69092. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69093. private _isBinary;
  69094. private _parseBinary;
  69095. private _parseASCII;
  69096. }
  69097. }
  69098. declare module BABYLON {
  69099. /**
  69100. * Class for generating OBJ data from a Babylon scene.
  69101. */
  69102. export class OBJExport {
  69103. /**
  69104. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69105. * @param mesh defines the list of meshes to serialize
  69106. * @param materials defines if materials should be exported
  69107. * @param matlibname defines the name of the associated mtl file
  69108. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69109. * @returns the OBJ content
  69110. */
  69111. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69112. /**
  69113. * Exports the material(s) of a mesh in .MTL file format (text)
  69114. * @param mesh defines the mesh to extract the material from
  69115. * @returns the mtl content
  69116. */
  69117. static MTL(mesh: Mesh): string;
  69118. }
  69119. }
  69120. declare module BABYLON {
  69121. /** @hidden */
  69122. export var __IGLTFExporterExtension: number;
  69123. /**
  69124. * Interface for extending the exporter
  69125. * @hidden
  69126. */
  69127. export interface IGLTFExporterExtension {
  69128. /**
  69129. * The name of this extension
  69130. */
  69131. readonly name: string;
  69132. /**
  69133. * Defines whether this extension is enabled
  69134. */
  69135. enabled: boolean;
  69136. /**
  69137. * Defines whether this extension is required
  69138. */
  69139. required: boolean;
  69140. }
  69141. }
  69142. declare module BABYLON.GLTF2.Exporter {
  69143. /** @hidden */
  69144. export var __IGLTFExporterExtensionV2: number;
  69145. /**
  69146. * Interface for a glTF exporter extension
  69147. * @hidden
  69148. */
  69149. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69150. /**
  69151. * Define this method to modify the default behavior before exporting a texture
  69152. * @param context The context when loading the asset
  69153. * @param babylonTexture The glTF texture info property
  69154. * @param mimeType The mime-type of the generated image
  69155. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69156. */
  69157. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69158. /**
  69159. * Define this method to modify the default behavior when exporting texture info
  69160. * @param context The context when loading the asset
  69161. * @param meshPrimitive glTF mesh primitive
  69162. * @param babylonSubMesh Babylon submesh
  69163. * @param binaryWriter glTF serializer binary writer instance
  69164. * @returns nullable IMeshPrimitive promise
  69165. */
  69166. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69167. /**
  69168. * Define this method to modify the default behavior when exporting a node
  69169. * @param context The context when exporting the node
  69170. * @param node glTF node
  69171. * @param babylonNode BabylonJS node
  69172. * @returns nullable INode promise
  69173. */
  69174. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69175. /**
  69176. * Called after the exporter state changes to EXPORTING
  69177. */
  69178. onExporting?(): void;
  69179. }
  69180. }
  69181. declare module BABYLON.GLTF2.Exporter {
  69182. /**
  69183. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69184. * @hidden
  69185. */
  69186. export class _GLTFMaterialExporter {
  69187. /**
  69188. * Represents the dielectric specular values for R, G and B
  69189. */
  69190. private static readonly _DielectricSpecular;
  69191. /**
  69192. * Allows the maximum specular power to be defined for material calculations
  69193. */
  69194. private static readonly _MaxSpecularPower;
  69195. /**
  69196. * Mapping to store textures
  69197. */
  69198. private _textureMap;
  69199. /**
  69200. * Numeric tolerance value
  69201. */
  69202. private static readonly _Epsilon;
  69203. /**
  69204. * Reference to the glTF Exporter
  69205. */
  69206. private _exporter;
  69207. constructor(exporter: _Exporter);
  69208. /**
  69209. * Specifies if two colors are approximately equal in value
  69210. * @param color1 first color to compare to
  69211. * @param color2 second color to compare to
  69212. * @param epsilon threshold value
  69213. */
  69214. private static FuzzyEquals;
  69215. /**
  69216. * Gets the materials from a Babylon scene and converts them to glTF materials
  69217. * @param scene babylonjs scene
  69218. * @param mimeType texture mime type
  69219. * @param images array of images
  69220. * @param textures array of textures
  69221. * @param materials array of materials
  69222. * @param imageData mapping of texture names to base64 textures
  69223. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69224. */
  69225. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69226. /**
  69227. * Makes a copy of the glTF material without the texture parameters
  69228. * @param originalMaterial original glTF material
  69229. * @returns glTF material without texture parameters
  69230. */
  69231. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69232. /**
  69233. * Specifies if the material has any texture parameters present
  69234. * @param material glTF Material
  69235. * @returns boolean specifying if texture parameters are present
  69236. */
  69237. _hasTexturesPresent(material: IMaterial): boolean;
  69238. /**
  69239. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69240. * @param babylonStandardMaterial
  69241. * @returns glTF Metallic Roughness Material representation
  69242. */
  69243. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69244. /**
  69245. * Computes the metallic factor
  69246. * @param diffuse diffused value
  69247. * @param specular specular value
  69248. * @param oneMinusSpecularStrength one minus the specular strength
  69249. * @returns metallic value
  69250. */
  69251. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69252. /**
  69253. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69254. * @param glTFMaterial glTF material
  69255. * @param babylonMaterial Babylon material
  69256. */
  69257. private static _SetAlphaMode;
  69258. /**
  69259. * Converts a Babylon Standard Material to a glTF Material
  69260. * @param babylonStandardMaterial BJS Standard Material
  69261. * @param mimeType mime type to use for the textures
  69262. * @param images array of glTF image interfaces
  69263. * @param textures array of glTF texture interfaces
  69264. * @param materials array of glTF material interfaces
  69265. * @param imageData map of image file name to data
  69266. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69267. */
  69268. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69269. /**
  69270. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69271. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69272. * @param mimeType mime type to use for the textures
  69273. * @param images array of glTF image interfaces
  69274. * @param textures array of glTF texture interfaces
  69275. * @param materials array of glTF material interfaces
  69276. * @param imageData map of image file name to data
  69277. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69278. */
  69279. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69280. /**
  69281. * Converts an image typed array buffer to a base64 image
  69282. * @param buffer typed array buffer
  69283. * @param width width of the image
  69284. * @param height height of the image
  69285. * @param mimeType mimetype of the image
  69286. * @returns base64 image string
  69287. */
  69288. private _createBase64FromCanvasAsync;
  69289. /**
  69290. * Generates a white texture based on the specified width and height
  69291. * @param width width of the texture in pixels
  69292. * @param height height of the texture in pixels
  69293. * @param scene babylonjs scene
  69294. * @returns white texture
  69295. */
  69296. private _createWhiteTexture;
  69297. /**
  69298. * 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
  69299. * @param texture1 first texture to resize
  69300. * @param texture2 second texture to resize
  69301. * @param scene babylonjs scene
  69302. * @returns resized textures or null
  69303. */
  69304. private _resizeTexturesToSameDimensions;
  69305. /**
  69306. * Converts an array of pixels to a Float32Array
  69307. * Throws an error if the pixel format is not supported
  69308. * @param pixels - array buffer containing pixel values
  69309. * @returns Float32 of pixels
  69310. */
  69311. private _convertPixelArrayToFloat32;
  69312. /**
  69313. * Convert Specular Glossiness Textures to Metallic Roughness
  69314. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69315. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69316. * @param diffuseTexture texture used to store diffuse information
  69317. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69318. * @param factors specular glossiness material factors
  69319. * @param mimeType the mime type to use for the texture
  69320. * @returns pbr metallic roughness interface or null
  69321. */
  69322. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69323. /**
  69324. * Converts specular glossiness material properties to metallic roughness
  69325. * @param specularGlossiness interface with specular glossiness material properties
  69326. * @returns interface with metallic roughness material properties
  69327. */
  69328. private _convertSpecularGlossinessToMetallicRoughness;
  69329. /**
  69330. * Calculates the surface reflectance, independent of lighting conditions
  69331. * @param color Color source to calculate brightness from
  69332. * @returns number representing the perceived brightness, or zero if color is undefined
  69333. */
  69334. private _getPerceivedBrightness;
  69335. /**
  69336. * Returns the maximum color component value
  69337. * @param color
  69338. * @returns maximum color component value, or zero if color is null or undefined
  69339. */
  69340. private _getMaxComponent;
  69341. /**
  69342. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69343. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69344. * @param mimeType mime type to use for the textures
  69345. * @param images array of glTF image interfaces
  69346. * @param textures array of glTF texture interfaces
  69347. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69348. * @param imageData map of image file name to data
  69349. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69350. * @returns glTF PBR Metallic Roughness factors
  69351. */
  69352. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69353. private _getGLTFTextureSampler;
  69354. private _getGLTFTextureWrapMode;
  69355. private _getGLTFTextureWrapModesSampler;
  69356. /**
  69357. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69358. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69359. * @param mimeType mime type to use for the textures
  69360. * @param images array of glTF image interfaces
  69361. * @param textures array of glTF texture interfaces
  69362. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69363. * @param imageData map of image file name to data
  69364. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69365. * @returns glTF PBR Metallic Roughness factors
  69366. */
  69367. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69368. /**
  69369. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69370. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69371. * @param mimeType mime type to use for the textures
  69372. * @param images array of glTF image interfaces
  69373. * @param textures array of glTF texture interfaces
  69374. * @param materials array of glTF material interfaces
  69375. * @param imageData map of image file name to data
  69376. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69377. */
  69378. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69379. private setMetallicRoughnessPbrMaterial;
  69380. private getPixelsFromTexture;
  69381. /**
  69382. * Extracts a texture from a Babylon texture into file data and glTF data
  69383. * @param babylonTexture Babylon texture to extract
  69384. * @param mimeType Mime Type of the babylonTexture
  69385. * @return glTF texture info, or null if the texture format is not supported
  69386. */
  69387. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69388. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69389. /**
  69390. * Builds a texture from base64 string
  69391. * @param base64Texture base64 texture string
  69392. * @param baseTextureName Name to use for the texture
  69393. * @param mimeType image mime type for the texture
  69394. * @param images array of images
  69395. * @param textures array of textures
  69396. * @param imageData map of image data
  69397. * @returns glTF texture info, or null if the texture format is not supported
  69398. */
  69399. private _getTextureInfoFromBase64;
  69400. }
  69401. }
  69402. declare module BABYLON {
  69403. /**
  69404. * Class for holding and downloading glTF file data
  69405. */
  69406. export class GLTFData {
  69407. /**
  69408. * Object which contains the file name as the key and its data as the value
  69409. */
  69410. glTFFiles: {
  69411. [fileName: string]: string | Blob;
  69412. };
  69413. /**
  69414. * Initializes the glTF file object
  69415. */
  69416. constructor();
  69417. /**
  69418. * Downloads the glTF data as files based on their names and data
  69419. */
  69420. downloadFiles(): void;
  69421. }
  69422. }
  69423. declare module BABYLON {
  69424. /**
  69425. * Holds a collection of exporter options and parameters
  69426. */
  69427. export interface IExportOptions {
  69428. /**
  69429. * Function which indicates whether a babylon node should be exported or not
  69430. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69431. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69432. */
  69433. shouldExportNode?(node: Node): boolean;
  69434. /**
  69435. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69436. * @param metadata source metadata to read from
  69437. * @returns the data to store to glTF node extras
  69438. */
  69439. metadataSelector?(metadata: any): any;
  69440. /**
  69441. * The sample rate to bake animation curves
  69442. */
  69443. animationSampleRate?: number;
  69444. /**
  69445. * Begin serialization without waiting for the scene to be ready
  69446. */
  69447. exportWithoutWaitingForScene?: boolean;
  69448. }
  69449. /**
  69450. * Class for generating glTF data from a Babylon scene.
  69451. */
  69452. export class GLTF2Export {
  69453. /**
  69454. * Exports the geometry of the scene to .gltf file format asynchronously
  69455. * @param scene Babylon scene with scene hierarchy information
  69456. * @param filePrefix File prefix to use when generating the glTF file
  69457. * @param options Exporter options
  69458. * @returns Returns an object with a .gltf file and associates texture names
  69459. * as keys and their data and paths as values
  69460. */
  69461. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69462. private static _PreExportAsync;
  69463. private static _PostExportAsync;
  69464. /**
  69465. * Exports the geometry of the scene to .glb file format asychronously
  69466. * @param scene Babylon scene with scene hierarchy information
  69467. * @param filePrefix File prefix to use when generating glb file
  69468. * @param options Exporter options
  69469. * @returns Returns an object with a .glb filename as key and data as value
  69470. */
  69471. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69472. }
  69473. }
  69474. declare module BABYLON.GLTF2.Exporter {
  69475. /**
  69476. * @hidden
  69477. */
  69478. export class _GLTFUtilities {
  69479. /**
  69480. * Creates a buffer view based on the supplied arguments
  69481. * @param bufferIndex index value of the specified buffer
  69482. * @param byteOffset byte offset value
  69483. * @param byteLength byte length of the bufferView
  69484. * @param byteStride byte distance between conequential elements
  69485. * @param name name of the buffer view
  69486. * @returns bufferView for glTF
  69487. */
  69488. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69489. /**
  69490. * Creates an accessor based on the supplied arguments
  69491. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69492. * @param name The name of the accessor
  69493. * @param type The type of the accessor
  69494. * @param componentType The datatype of components in the attribute
  69495. * @param count The number of attributes referenced by this accessor
  69496. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69497. * @param min Minimum value of each component in this attribute
  69498. * @param max Maximum value of each component in this attribute
  69499. * @returns accessor for glTF
  69500. */
  69501. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69502. /**
  69503. * Calculates the minimum and maximum values of an array of position floats
  69504. * @param positions Positions array of a mesh
  69505. * @param vertexStart Starting vertex offset to calculate min and max values
  69506. * @param vertexCount Number of vertices to check for min and max values
  69507. * @returns min number array and max number array
  69508. */
  69509. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69510. min: number[];
  69511. max: number[];
  69512. };
  69513. /**
  69514. * Converts a new right-handed Vector3
  69515. * @param vector vector3 array
  69516. * @returns right-handed Vector3
  69517. */
  69518. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69519. /**
  69520. * Converts a Vector3 to right-handed
  69521. * @param vector Vector3 to convert to right-handed
  69522. */
  69523. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69524. /**
  69525. * Converts a three element number array to right-handed
  69526. * @param vector number array to convert to right-handed
  69527. */
  69528. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69529. /**
  69530. * Converts a new right-handed Vector3
  69531. * @param vector vector3 array
  69532. * @returns right-handed Vector3
  69533. */
  69534. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69535. /**
  69536. * Converts a Vector3 to right-handed
  69537. * @param vector Vector3 to convert to right-handed
  69538. */
  69539. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69540. /**
  69541. * Converts a three element number array to right-handed
  69542. * @param vector number array to convert to right-handed
  69543. */
  69544. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69545. /**
  69546. * Converts a Vector4 to right-handed
  69547. * @param vector Vector4 to convert to right-handed
  69548. */
  69549. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69550. /**
  69551. * Converts a Vector4 to right-handed
  69552. * @param vector Vector4 to convert to right-handed
  69553. */
  69554. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69555. /**
  69556. * Converts a Quaternion to right-handed
  69557. * @param quaternion Source quaternion to convert to right-handed
  69558. */
  69559. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69560. /**
  69561. * Converts a Quaternion to right-handed
  69562. * @param quaternion Source quaternion to convert to right-handed
  69563. */
  69564. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69565. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69566. }
  69567. }
  69568. declare module BABYLON.GLTF2.Exporter {
  69569. /**
  69570. * Converts Babylon Scene into glTF 2.0.
  69571. * @hidden
  69572. */
  69573. export class _Exporter {
  69574. /**
  69575. * Stores the glTF to export
  69576. */
  69577. _glTF: IGLTF;
  69578. /**
  69579. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69580. */
  69581. _bufferViews: IBufferView[];
  69582. /**
  69583. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69584. */
  69585. _accessors: IAccessor[];
  69586. /**
  69587. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69588. */
  69589. private _nodes;
  69590. /**
  69591. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69592. */
  69593. private _scenes;
  69594. /**
  69595. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69596. */
  69597. private _meshes;
  69598. /**
  69599. * Stores all the generated material information, which represents the appearance of each primitive
  69600. */
  69601. _materials: IMaterial[];
  69602. _materialMap: {
  69603. [materialID: number]: number;
  69604. };
  69605. /**
  69606. * Stores all the generated texture information, which is referenced by glTF materials
  69607. */
  69608. _textures: ITexture[];
  69609. /**
  69610. * Stores all the generated image information, which is referenced by glTF textures
  69611. */
  69612. _images: IImage[];
  69613. /**
  69614. * Stores all the texture samplers
  69615. */
  69616. _samplers: ISampler[];
  69617. /**
  69618. * Stores all the generated animation samplers, which is referenced by glTF animations
  69619. */
  69620. /**
  69621. * Stores the animations for glTF models
  69622. */
  69623. private _animations;
  69624. /**
  69625. * Stores the total amount of bytes stored in the glTF buffer
  69626. */
  69627. private _totalByteLength;
  69628. /**
  69629. * Stores a reference to the Babylon scene containing the source geometry and material information
  69630. */
  69631. _babylonScene: Scene;
  69632. /**
  69633. * Stores a map of the image data, where the key is the file name and the value
  69634. * is the image data
  69635. */
  69636. _imageData: {
  69637. [fileName: string]: {
  69638. data: Uint8Array;
  69639. mimeType: ImageMimeType;
  69640. };
  69641. };
  69642. /**
  69643. * Stores a map of the unique id of a node to its index in the node array
  69644. */
  69645. private _nodeMap;
  69646. /**
  69647. * Specifies if the Babylon scene should be converted to right-handed on export
  69648. */
  69649. _convertToRightHandedSystem: boolean;
  69650. /**
  69651. * Baked animation sample rate
  69652. */
  69653. private _animationSampleRate;
  69654. private _options;
  69655. private _localEngine;
  69656. _glTFMaterialExporter: _GLTFMaterialExporter;
  69657. private _extensions;
  69658. private static _ExtensionNames;
  69659. private static _ExtensionFactories;
  69660. private _applyExtensions;
  69661. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69662. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69663. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69664. private _forEachExtensions;
  69665. private _extensionsOnExporting;
  69666. /**
  69667. * Load glTF serializer extensions
  69668. */
  69669. private _loadExtensions;
  69670. /**
  69671. * Creates a glTF Exporter instance, which can accept optional exporter options
  69672. * @param babylonScene Babylon scene object
  69673. * @param options Options to modify the behavior of the exporter
  69674. */
  69675. constructor(babylonScene: Scene, options?: IExportOptions);
  69676. /**
  69677. * Registers a glTF exporter extension
  69678. * @param name Name of the extension to export
  69679. * @param factory The factory function that creates the exporter extension
  69680. */
  69681. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69682. /**
  69683. * Un-registers an exporter extension
  69684. * @param name The name fo the exporter extension
  69685. * @returns A boolean indicating whether the extension has been un-registered
  69686. */
  69687. static UnregisterExtension(name: string): boolean;
  69688. /**
  69689. * Lazy load a local engine with premultiplied alpha set to false
  69690. */
  69691. _getLocalEngine(): Engine;
  69692. private reorderIndicesBasedOnPrimitiveMode;
  69693. /**
  69694. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69695. * clock-wise during export to glTF
  69696. * @param submesh BabylonJS submesh
  69697. * @param primitiveMode Primitive mode of the mesh
  69698. * @param sideOrientation the winding order of the submesh
  69699. * @param vertexBufferKind The type of vertex attribute
  69700. * @param meshAttributeArray The vertex attribute data
  69701. * @param byteOffset The offset to the binary data
  69702. * @param binaryWriter The binary data for the glTF file
  69703. */
  69704. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69705. /**
  69706. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69707. * clock-wise during export to glTF
  69708. * @param submesh BabylonJS submesh
  69709. * @param primitiveMode Primitive mode of the mesh
  69710. * @param sideOrientation the winding order of the submesh
  69711. * @param vertexBufferKind The type of vertex attribute
  69712. * @param meshAttributeArray The vertex attribute data
  69713. * @param byteOffset The offset to the binary data
  69714. * @param binaryWriter The binary data for the glTF file
  69715. */
  69716. private reorderTriangleFillMode;
  69717. /**
  69718. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69719. * clock-wise during export to glTF
  69720. * @param submesh BabylonJS submesh
  69721. * @param primitiveMode Primitive mode of the mesh
  69722. * @param sideOrientation the winding order of the submesh
  69723. * @param vertexBufferKind The type of vertex attribute
  69724. * @param meshAttributeArray The vertex attribute data
  69725. * @param byteOffset The offset to the binary data
  69726. * @param binaryWriter The binary data for the glTF file
  69727. */
  69728. private reorderTriangleStripDrawMode;
  69729. /**
  69730. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69731. * clock-wise during export to glTF
  69732. * @param submesh BabylonJS submesh
  69733. * @param primitiveMode Primitive mode of the mesh
  69734. * @param sideOrientation the winding order of the submesh
  69735. * @param vertexBufferKind The type of vertex attribute
  69736. * @param meshAttributeArray The vertex attribute data
  69737. * @param byteOffset The offset to the binary data
  69738. * @param binaryWriter The binary data for the glTF file
  69739. */
  69740. private reorderTriangleFanMode;
  69741. /**
  69742. * Writes the vertex attribute data to binary
  69743. * @param vertices The vertices to write to the binary writer
  69744. * @param byteOffset The offset into the binary writer to overwrite binary data
  69745. * @param vertexAttributeKind The vertex attribute type
  69746. * @param meshAttributeArray The vertex attribute data
  69747. * @param binaryWriter The writer containing the binary data
  69748. */
  69749. private writeVertexAttributeData;
  69750. /**
  69751. * Writes mesh attribute data to a data buffer
  69752. * Returns the bytelength of the data
  69753. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69754. * @param meshAttributeArray Array containing the attribute data
  69755. * @param binaryWriter The buffer to write the binary data to
  69756. * @param indices Used to specify the order of the vertex data
  69757. */
  69758. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69759. /**
  69760. * Generates glTF json data
  69761. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69762. * @param glTFPrefix Text to use when prefixing a glTF file
  69763. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69764. * @returns json data as string
  69765. */
  69766. private generateJSON;
  69767. /**
  69768. * Generates data for .gltf and .bin files based on the glTF prefix string
  69769. * @param glTFPrefix Text to use when prefixing a glTF file
  69770. * @returns GLTFData with glTF file data
  69771. */
  69772. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69773. /**
  69774. * Creates a binary buffer for glTF
  69775. * @returns array buffer for binary data
  69776. */
  69777. private _generateBinaryAsync;
  69778. /**
  69779. * Pads the number to a multiple of 4
  69780. * @param num number to pad
  69781. * @returns padded number
  69782. */
  69783. private _getPadding;
  69784. /**
  69785. * Generates a glb file from the json and binary data
  69786. * Returns an object with the glb file name as the key and data as the value
  69787. * @param glTFPrefix
  69788. * @returns object with glb filename as key and data as value
  69789. */
  69790. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69791. /**
  69792. * Sets the TRS for each node
  69793. * @param node glTF Node for storing the transformation data
  69794. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69795. */
  69796. private setNodeTransformation;
  69797. private getVertexBufferFromMesh;
  69798. /**
  69799. * Creates a bufferview based on the vertices type for the Babylon mesh
  69800. * @param kind Indicates the type of vertices data
  69801. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69802. * @param binaryWriter The buffer to write the bufferview data to
  69803. */
  69804. private createBufferViewKind;
  69805. /**
  69806. * The primitive mode of the Babylon mesh
  69807. * @param babylonMesh The BabylonJS mesh
  69808. */
  69809. private getMeshPrimitiveMode;
  69810. /**
  69811. * Sets the primitive mode of the glTF mesh primitive
  69812. * @param meshPrimitive glTF mesh primitive
  69813. * @param primitiveMode The primitive mode
  69814. */
  69815. private setPrimitiveMode;
  69816. /**
  69817. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69818. * @param meshPrimitive glTF mesh primitive
  69819. * @param attributeKind vertex attribute
  69820. * @returns boolean specifying if uv coordinates are present
  69821. */
  69822. private setAttributeKind;
  69823. /**
  69824. * Sets data for the primitive attributes of each submesh
  69825. * @param mesh glTF Mesh object to store the primitive attribute information
  69826. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69827. * @param binaryWriter Buffer to write the attribute data to
  69828. */
  69829. private setPrimitiveAttributesAsync;
  69830. /**
  69831. * Creates a glTF scene based on the array of meshes
  69832. * Returns the the total byte offset
  69833. * @param babylonScene Babylon scene to get the mesh data from
  69834. * @param binaryWriter Buffer to write binary data to
  69835. */
  69836. private createSceneAsync;
  69837. /**
  69838. * Creates a mapping of Node unique id to node index and handles animations
  69839. * @param babylonScene Babylon Scene
  69840. * @param nodes Babylon transform nodes
  69841. * @param binaryWriter Buffer to write binary data to
  69842. * @returns Node mapping of unique id to index
  69843. */
  69844. private createNodeMapAndAnimationsAsync;
  69845. /**
  69846. * Creates a glTF node from a Babylon mesh
  69847. * @param babylonMesh Source Babylon mesh
  69848. * @param binaryWriter Buffer for storing geometry data
  69849. * @returns glTF node
  69850. */
  69851. private createNodeAsync;
  69852. }
  69853. /**
  69854. * @hidden
  69855. *
  69856. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69857. */
  69858. export class _BinaryWriter {
  69859. /**
  69860. * Array buffer which stores all binary data
  69861. */
  69862. private _arrayBuffer;
  69863. /**
  69864. * View of the array buffer
  69865. */
  69866. private _dataView;
  69867. /**
  69868. * byte offset of data in array buffer
  69869. */
  69870. private _byteOffset;
  69871. /**
  69872. * Initialize binary writer with an initial byte length
  69873. * @param byteLength Initial byte length of the array buffer
  69874. */
  69875. constructor(byteLength: number);
  69876. /**
  69877. * Resize the array buffer to the specified byte length
  69878. * @param byteLength
  69879. */
  69880. private resizeBuffer;
  69881. /**
  69882. * Get an array buffer with the length of the byte offset
  69883. * @returns ArrayBuffer resized to the byte offset
  69884. */
  69885. getArrayBuffer(): ArrayBuffer;
  69886. /**
  69887. * Get the byte offset of the array buffer
  69888. * @returns byte offset
  69889. */
  69890. getByteOffset(): number;
  69891. /**
  69892. * Stores an UInt8 in the array buffer
  69893. * @param entry
  69894. * @param byteOffset If defined, specifies where to set the value as an offset.
  69895. */
  69896. setUInt8(entry: number, byteOffset?: number): void;
  69897. /**
  69898. * Gets an UInt32 in the array buffer
  69899. * @param entry
  69900. * @param byteOffset If defined, specifies where to set the value as an offset.
  69901. */
  69902. getUInt32(byteOffset: number): number;
  69903. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69904. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69905. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69906. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69907. /**
  69908. * Stores a Float32 in the array buffer
  69909. * @param entry
  69910. */
  69911. setFloat32(entry: number, byteOffset?: number): void;
  69912. /**
  69913. * Stores an UInt32 in the array buffer
  69914. * @param entry
  69915. * @param byteOffset If defined, specifies where to set the value as an offset.
  69916. */
  69917. setUInt32(entry: number, byteOffset?: number): void;
  69918. }
  69919. }
  69920. declare module BABYLON.GLTF2.Exporter {
  69921. /**
  69922. * @hidden
  69923. * Interface to store animation data.
  69924. */
  69925. export interface _IAnimationData {
  69926. /**
  69927. * Keyframe data.
  69928. */
  69929. inputs: number[];
  69930. /**
  69931. * Value data.
  69932. */
  69933. outputs: number[][];
  69934. /**
  69935. * Animation interpolation data.
  69936. */
  69937. samplerInterpolation: AnimationSamplerInterpolation;
  69938. /**
  69939. * Minimum keyframe value.
  69940. */
  69941. inputsMin: number;
  69942. /**
  69943. * Maximum keyframe value.
  69944. */
  69945. inputsMax: number;
  69946. }
  69947. /**
  69948. * @hidden
  69949. */
  69950. export interface _IAnimationInfo {
  69951. /**
  69952. * The target channel for the animation
  69953. */
  69954. animationChannelTargetPath: AnimationChannelTargetPath;
  69955. /**
  69956. * The glTF accessor type for the data.
  69957. */
  69958. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69959. /**
  69960. * Specifies if quaternions should be used.
  69961. */
  69962. useQuaternion: boolean;
  69963. }
  69964. /**
  69965. * @hidden
  69966. * Utility class for generating glTF animation data from BabylonJS.
  69967. */
  69968. export class _GLTFAnimation {
  69969. /**
  69970. * @ignore
  69971. *
  69972. * Creates glTF channel animation from BabylonJS animation.
  69973. * @param babylonTransformNode - BabylonJS mesh.
  69974. * @param animation - animation.
  69975. * @param animationChannelTargetPath - The target animation channel.
  69976. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69977. * @param useQuaternion - Specifies if quaternions are used.
  69978. * @returns nullable IAnimationData
  69979. */
  69980. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69981. private static _DeduceAnimationInfo;
  69982. /**
  69983. * @ignore
  69984. * Create node animations from the transform node animations
  69985. * @param babylonNode
  69986. * @param runtimeGLTFAnimation
  69987. * @param idleGLTFAnimations
  69988. * @param nodeMap
  69989. * @param nodes
  69990. * @param binaryWriter
  69991. * @param bufferViews
  69992. * @param accessors
  69993. * @param convertToRightHandedSystem
  69994. */
  69995. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69996. [key: number]: number;
  69997. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69998. /**
  69999. * @ignore
  70000. * Create node animations from the animation groups
  70001. * @param babylonScene
  70002. * @param glTFAnimations
  70003. * @param nodeMap
  70004. * @param nodes
  70005. * @param binaryWriter
  70006. * @param bufferViews
  70007. * @param accessors
  70008. * @param convertToRightHandedSystem
  70009. */
  70010. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70011. [key: number]: number;
  70012. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70013. private static AddAnimation;
  70014. /**
  70015. * Create a baked animation
  70016. * @param babylonTransformNode BabylonJS mesh
  70017. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70018. * @param animationChannelTargetPath animation target channel
  70019. * @param minFrame minimum animation frame
  70020. * @param maxFrame maximum animation frame
  70021. * @param fps frames per second of the animation
  70022. * @param inputs input key frames of the animation
  70023. * @param outputs output key frame data of the animation
  70024. * @param convertToRightHandedSystem converts the values to right-handed
  70025. * @param useQuaternion specifies if quaternions should be used
  70026. */
  70027. private static _CreateBakedAnimation;
  70028. private static _ConvertFactorToVector3OrQuaternion;
  70029. private static _SetInterpolatedValue;
  70030. /**
  70031. * Creates linear animation from the animation key frames
  70032. * @param babylonTransformNode BabylonJS mesh
  70033. * @param animation BabylonJS animation
  70034. * @param animationChannelTargetPath The target animation channel
  70035. * @param frameDelta The difference between the last and first frame of the animation
  70036. * @param inputs Array to store the key frame times
  70037. * @param outputs Array to store the key frame data
  70038. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70039. * @param useQuaternion Specifies if quaternions are used in the animation
  70040. */
  70041. private static _CreateLinearOrStepAnimation;
  70042. /**
  70043. * Creates cubic spline animation from the animation key frames
  70044. * @param babylonTransformNode BabylonJS mesh
  70045. * @param animation BabylonJS animation
  70046. * @param animationChannelTargetPath The target animation channel
  70047. * @param frameDelta The difference between the last and first frame of the animation
  70048. * @param inputs Array to store the key frame times
  70049. * @param outputs Array to store the key frame data
  70050. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70051. * @param useQuaternion Specifies if quaternions are used in the animation
  70052. */
  70053. private static _CreateCubicSplineAnimation;
  70054. private static _GetBasePositionRotationOrScale;
  70055. /**
  70056. * Adds a key frame value
  70057. * @param keyFrame
  70058. * @param animation
  70059. * @param outputs
  70060. * @param animationChannelTargetPath
  70061. * @param basePositionRotationOrScale
  70062. * @param convertToRightHandedSystem
  70063. * @param useQuaternion
  70064. */
  70065. private static _AddKeyframeValue;
  70066. /**
  70067. * Determine the interpolation based on the key frames
  70068. * @param keyFrames
  70069. * @param animationChannelTargetPath
  70070. * @param useQuaternion
  70071. */
  70072. private static _DeduceInterpolation;
  70073. /**
  70074. * Adds an input tangent or output tangent to the output data
  70075. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70076. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70077. * @param outputs The animation data by keyframe
  70078. * @param animationChannelTargetPath The target animation channel
  70079. * @param interpolation The interpolation type
  70080. * @param keyFrame The key frame with the animation data
  70081. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70082. * @param useQuaternion Specifies if quaternions are used
  70083. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70084. */
  70085. private static AddSplineTangent;
  70086. /**
  70087. * Get the minimum and maximum key frames' frame values
  70088. * @param keyFrames animation key frames
  70089. * @returns the minimum and maximum key frame value
  70090. */
  70091. private static calculateMinMaxKeyFrames;
  70092. }
  70093. }
  70094. declare module BABYLON.GLTF2.Exporter {
  70095. /** @hidden */
  70096. export var textureTransformPixelShader: {
  70097. name: string;
  70098. shader: string;
  70099. };
  70100. }
  70101. declare module BABYLON.GLTF2.Exporter.Extensions {
  70102. /**
  70103. * @hidden
  70104. */
  70105. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70106. /** Name of this extension */
  70107. readonly name: string;
  70108. /** Defines whether this extension is enabled */
  70109. enabled: boolean;
  70110. /** Defines whether this extension is required */
  70111. required: boolean;
  70112. /** Reference to the glTF exporter */
  70113. private _exporter;
  70114. constructor(exporter: _Exporter);
  70115. dispose(): void;
  70116. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70117. /**
  70118. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70119. * @param babylonTexture
  70120. * @param offset
  70121. * @param rotation
  70122. * @param scale
  70123. * @param scene
  70124. */
  70125. private _textureTransformTextureAsync;
  70126. }
  70127. }
  70128. declare module BABYLON.GLTF2.Exporter.Extensions {
  70129. /**
  70130. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70131. */
  70132. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70133. /** The name of this extension. */
  70134. readonly name: string;
  70135. /** Defines whether this extension is enabled. */
  70136. enabled: boolean;
  70137. /** Defines whether this extension is required */
  70138. required: boolean;
  70139. /** Reference to the glTF exporter */
  70140. private _exporter;
  70141. private _lights;
  70142. /** @hidden */
  70143. constructor(exporter: _Exporter);
  70144. /** @hidden */
  70145. dispose(): void;
  70146. /** @hidden */
  70147. onExporting(): void;
  70148. /**
  70149. * Define this method to modify the default behavior when exporting a node
  70150. * @param context The context when exporting the node
  70151. * @param node glTF node
  70152. * @param babylonNode BabylonJS node
  70153. * @returns nullable INode promise
  70154. */
  70155. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70156. }
  70157. }
  70158. declare module BABYLON {
  70159. /**
  70160. * Class for generating STL data from a Babylon scene.
  70161. */
  70162. export class STLExport {
  70163. /**
  70164. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70165. * @param meshes list defines the mesh to serialize
  70166. * @param download triggers the automatic download of the file.
  70167. * @param fileName changes the downloads fileName.
  70168. * @param binary changes the STL to a binary type.
  70169. * @param isLittleEndian toggle for binary type exporter.
  70170. * @returns the STL as UTF8 string
  70171. */
  70172. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70173. }
  70174. }
  70175. declare module "babylonjs-gltf2interface" {
  70176. export = BABYLON.GLTF2;
  70177. }
  70178. /**
  70179. * Module for glTF 2.0 Interface
  70180. */
  70181. declare module BABYLON.GLTF2 {
  70182. /**
  70183. * The datatype of the components in the attribute
  70184. */
  70185. const enum AccessorComponentType {
  70186. /**
  70187. * Byte
  70188. */
  70189. BYTE = 5120,
  70190. /**
  70191. * Unsigned Byte
  70192. */
  70193. UNSIGNED_BYTE = 5121,
  70194. /**
  70195. * Short
  70196. */
  70197. SHORT = 5122,
  70198. /**
  70199. * Unsigned Short
  70200. */
  70201. UNSIGNED_SHORT = 5123,
  70202. /**
  70203. * Unsigned Int
  70204. */
  70205. UNSIGNED_INT = 5125,
  70206. /**
  70207. * Float
  70208. */
  70209. FLOAT = 5126,
  70210. }
  70211. /**
  70212. * Specifies if the attirbute is a scalar, vector, or matrix
  70213. */
  70214. const enum AccessorType {
  70215. /**
  70216. * Scalar
  70217. */
  70218. SCALAR = "SCALAR",
  70219. /**
  70220. * Vector2
  70221. */
  70222. VEC2 = "VEC2",
  70223. /**
  70224. * Vector3
  70225. */
  70226. VEC3 = "VEC3",
  70227. /**
  70228. * Vector4
  70229. */
  70230. VEC4 = "VEC4",
  70231. /**
  70232. * Matrix2x2
  70233. */
  70234. MAT2 = "MAT2",
  70235. /**
  70236. * Matrix3x3
  70237. */
  70238. MAT3 = "MAT3",
  70239. /**
  70240. * Matrix4x4
  70241. */
  70242. MAT4 = "MAT4",
  70243. }
  70244. /**
  70245. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70246. */
  70247. const enum AnimationChannelTargetPath {
  70248. /**
  70249. * Translation
  70250. */
  70251. TRANSLATION = "translation",
  70252. /**
  70253. * Rotation
  70254. */
  70255. ROTATION = "rotation",
  70256. /**
  70257. * Scale
  70258. */
  70259. SCALE = "scale",
  70260. /**
  70261. * Weights
  70262. */
  70263. WEIGHTS = "weights",
  70264. }
  70265. /**
  70266. * Interpolation algorithm
  70267. */
  70268. const enum AnimationSamplerInterpolation {
  70269. /**
  70270. * The animated values are linearly interpolated between keyframes
  70271. */
  70272. LINEAR = "LINEAR",
  70273. /**
  70274. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70275. */
  70276. STEP = "STEP",
  70277. /**
  70278. * The animation's interpolation is computed using a cubic spline with specified tangents
  70279. */
  70280. CUBICSPLINE = "CUBICSPLINE",
  70281. }
  70282. /**
  70283. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70284. */
  70285. const enum CameraType {
  70286. /**
  70287. * A perspective camera containing properties to create a perspective projection matrix
  70288. */
  70289. PERSPECTIVE = "perspective",
  70290. /**
  70291. * An orthographic camera containing properties to create an orthographic projection matrix
  70292. */
  70293. ORTHOGRAPHIC = "orthographic",
  70294. }
  70295. /**
  70296. * The mime-type of the image
  70297. */
  70298. const enum ImageMimeType {
  70299. /**
  70300. * JPEG Mime-type
  70301. */
  70302. JPEG = "image/jpeg",
  70303. /**
  70304. * PNG Mime-type
  70305. */
  70306. PNG = "image/png",
  70307. }
  70308. /**
  70309. * The alpha rendering mode of the material
  70310. */
  70311. const enum MaterialAlphaMode {
  70312. /**
  70313. * The alpha value is ignored and the rendered output is fully opaque
  70314. */
  70315. OPAQUE = "OPAQUE",
  70316. /**
  70317. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70318. */
  70319. MASK = "MASK",
  70320. /**
  70321. * 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)
  70322. */
  70323. BLEND = "BLEND",
  70324. }
  70325. /**
  70326. * The type of the primitives to render
  70327. */
  70328. const enum MeshPrimitiveMode {
  70329. /**
  70330. * Points
  70331. */
  70332. POINTS = 0,
  70333. /**
  70334. * Lines
  70335. */
  70336. LINES = 1,
  70337. /**
  70338. * Line Loop
  70339. */
  70340. LINE_LOOP = 2,
  70341. /**
  70342. * Line Strip
  70343. */
  70344. LINE_STRIP = 3,
  70345. /**
  70346. * Triangles
  70347. */
  70348. TRIANGLES = 4,
  70349. /**
  70350. * Triangle Strip
  70351. */
  70352. TRIANGLE_STRIP = 5,
  70353. /**
  70354. * Triangle Fan
  70355. */
  70356. TRIANGLE_FAN = 6,
  70357. }
  70358. /**
  70359. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70360. */
  70361. const enum TextureMagFilter {
  70362. /**
  70363. * Nearest
  70364. */
  70365. NEAREST = 9728,
  70366. /**
  70367. * Linear
  70368. */
  70369. LINEAR = 9729,
  70370. }
  70371. /**
  70372. * Minification filter. All valid values correspond to WebGL enums
  70373. */
  70374. const enum TextureMinFilter {
  70375. /**
  70376. * Nearest
  70377. */
  70378. NEAREST = 9728,
  70379. /**
  70380. * Linear
  70381. */
  70382. LINEAR = 9729,
  70383. /**
  70384. * Nearest Mip-Map Nearest
  70385. */
  70386. NEAREST_MIPMAP_NEAREST = 9984,
  70387. /**
  70388. * Linear Mipmap Nearest
  70389. */
  70390. LINEAR_MIPMAP_NEAREST = 9985,
  70391. /**
  70392. * Nearest Mipmap Linear
  70393. */
  70394. NEAREST_MIPMAP_LINEAR = 9986,
  70395. /**
  70396. * Linear Mipmap Linear
  70397. */
  70398. LINEAR_MIPMAP_LINEAR = 9987,
  70399. }
  70400. /**
  70401. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70402. */
  70403. const enum TextureWrapMode {
  70404. /**
  70405. * Clamp to Edge
  70406. */
  70407. CLAMP_TO_EDGE = 33071,
  70408. /**
  70409. * Mirrored Repeat
  70410. */
  70411. MIRRORED_REPEAT = 33648,
  70412. /**
  70413. * Repeat
  70414. */
  70415. REPEAT = 10497,
  70416. }
  70417. /**
  70418. * glTF Property
  70419. */
  70420. interface IProperty {
  70421. /**
  70422. * Dictionary object with extension-specific objects
  70423. */
  70424. extensions?: {
  70425. [key: string]: any;
  70426. };
  70427. /**
  70428. * Application-Specific data
  70429. */
  70430. extras?: any;
  70431. }
  70432. /**
  70433. * glTF Child of Root Property
  70434. */
  70435. interface IChildRootProperty extends IProperty {
  70436. /**
  70437. * The user-defined name of this object
  70438. */
  70439. name?: string;
  70440. }
  70441. /**
  70442. * Indices of those attributes that deviate from their initialization value
  70443. */
  70444. interface IAccessorSparseIndices extends IProperty {
  70445. /**
  70446. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70447. */
  70448. bufferView: number;
  70449. /**
  70450. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70451. */
  70452. byteOffset?: number;
  70453. /**
  70454. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70455. */
  70456. componentType: AccessorComponentType;
  70457. }
  70458. /**
  70459. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70460. */
  70461. interface IAccessorSparseValues extends IProperty {
  70462. /**
  70463. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70464. */
  70465. bufferView: number;
  70466. /**
  70467. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70468. */
  70469. byteOffset?: number;
  70470. }
  70471. /**
  70472. * Sparse storage of attributes that deviate from their initialization value
  70473. */
  70474. interface IAccessorSparse extends IProperty {
  70475. /**
  70476. * The number of attributes encoded in this sparse accessor
  70477. */
  70478. count: number;
  70479. /**
  70480. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70481. */
  70482. indices: IAccessorSparseIndices;
  70483. /**
  70484. * 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
  70485. */
  70486. values: IAccessorSparseValues;
  70487. }
  70488. /**
  70489. * 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
  70490. */
  70491. interface IAccessor extends IChildRootProperty {
  70492. /**
  70493. * The index of the bufferview
  70494. */
  70495. bufferView?: number;
  70496. /**
  70497. * The offset relative to the start of the bufferView in bytes
  70498. */
  70499. byteOffset?: number;
  70500. /**
  70501. * The datatype of components in the attribute
  70502. */
  70503. componentType: AccessorComponentType;
  70504. /**
  70505. * Specifies whether integer data values should be normalized
  70506. */
  70507. normalized?: boolean;
  70508. /**
  70509. * The number of attributes referenced by this accessor
  70510. */
  70511. count: number;
  70512. /**
  70513. * Specifies if the attribute is a scalar, vector, or matrix
  70514. */
  70515. type: AccessorType;
  70516. /**
  70517. * Maximum value of each component in this attribute
  70518. */
  70519. max?: number[];
  70520. /**
  70521. * Minimum value of each component in this attribute
  70522. */
  70523. min?: number[];
  70524. /**
  70525. * Sparse storage of attributes that deviate from their initialization value
  70526. */
  70527. sparse?: IAccessorSparse;
  70528. }
  70529. /**
  70530. * Targets an animation's sampler at a node's property
  70531. */
  70532. interface IAnimationChannel extends IProperty {
  70533. /**
  70534. * The index of a sampler in this animation used to compute the value for the target
  70535. */
  70536. sampler: number;
  70537. /**
  70538. * The index of the node and TRS property to target
  70539. */
  70540. target: IAnimationChannelTarget;
  70541. }
  70542. /**
  70543. * The index of the node and TRS property that an animation channel targets
  70544. */
  70545. interface IAnimationChannelTarget extends IProperty {
  70546. /**
  70547. * The index of the node to target
  70548. */
  70549. node: number;
  70550. /**
  70551. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70552. */
  70553. path: AnimationChannelTargetPath;
  70554. }
  70555. /**
  70556. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70557. */
  70558. interface IAnimationSampler extends IProperty {
  70559. /**
  70560. * The index of an accessor containing keyframe input values, e.g., time
  70561. */
  70562. input: number;
  70563. /**
  70564. * Interpolation algorithm
  70565. */
  70566. interpolation?: AnimationSamplerInterpolation;
  70567. /**
  70568. * The index of an accessor, containing keyframe output values
  70569. */
  70570. output: number;
  70571. }
  70572. /**
  70573. * A keyframe animation
  70574. */
  70575. interface IAnimation extends IChildRootProperty {
  70576. /**
  70577. * An array of channels, each of which targets an animation's sampler at a node's property
  70578. */
  70579. channels: IAnimationChannel[];
  70580. /**
  70581. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70582. */
  70583. samplers: IAnimationSampler[];
  70584. }
  70585. /**
  70586. * Metadata about the glTF asset
  70587. */
  70588. interface IAsset extends IChildRootProperty {
  70589. /**
  70590. * A copyright message suitable for display to credit the content creator
  70591. */
  70592. copyright?: string;
  70593. /**
  70594. * Tool that generated this glTF model. Useful for debugging
  70595. */
  70596. generator?: string;
  70597. /**
  70598. * The glTF version that this asset targets
  70599. */
  70600. version: string;
  70601. /**
  70602. * The minimum glTF version that this asset targets
  70603. */
  70604. minVersion?: string;
  70605. }
  70606. /**
  70607. * A buffer points to binary geometry, animation, or skins
  70608. */
  70609. interface IBuffer extends IChildRootProperty {
  70610. /**
  70611. * 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
  70612. */
  70613. uri?: string;
  70614. /**
  70615. * The length of the buffer in bytes
  70616. */
  70617. byteLength: number;
  70618. }
  70619. /**
  70620. * A view into a buffer generally representing a subset of the buffer
  70621. */
  70622. interface IBufferView extends IChildRootProperty {
  70623. /**
  70624. * The index of the buffer
  70625. */
  70626. buffer: number;
  70627. /**
  70628. * The offset into the buffer in bytes
  70629. */
  70630. byteOffset?: number;
  70631. /**
  70632. * The lenth of the bufferView in bytes
  70633. */
  70634. byteLength: number;
  70635. /**
  70636. * The stride, in bytes
  70637. */
  70638. byteStride?: number;
  70639. }
  70640. /**
  70641. * An orthographic camera containing properties to create an orthographic projection matrix
  70642. */
  70643. interface ICameraOrthographic extends IProperty {
  70644. /**
  70645. * The floating-point horizontal magnification of the view. Must not be zero
  70646. */
  70647. xmag: number;
  70648. /**
  70649. * The floating-point vertical magnification of the view. Must not be zero
  70650. */
  70651. ymag: number;
  70652. /**
  70653. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70654. */
  70655. zfar: number;
  70656. /**
  70657. * The floating-point distance to the near clipping plane
  70658. */
  70659. znear: number;
  70660. }
  70661. /**
  70662. * A perspective camera containing properties to create a perspective projection matrix
  70663. */
  70664. interface ICameraPerspective extends IProperty {
  70665. /**
  70666. * The floating-point aspect ratio of the field of view
  70667. */
  70668. aspectRatio?: number;
  70669. /**
  70670. * The floating-point vertical field of view in radians
  70671. */
  70672. yfov: number;
  70673. /**
  70674. * The floating-point distance to the far clipping plane
  70675. */
  70676. zfar?: number;
  70677. /**
  70678. * The floating-point distance to the near clipping plane
  70679. */
  70680. znear: number;
  70681. }
  70682. /**
  70683. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70684. */
  70685. interface ICamera extends IChildRootProperty {
  70686. /**
  70687. * An orthographic camera containing properties to create an orthographic projection matrix
  70688. */
  70689. orthographic?: ICameraOrthographic;
  70690. /**
  70691. * A perspective camera containing properties to create a perspective projection matrix
  70692. */
  70693. perspective?: ICameraPerspective;
  70694. /**
  70695. * Specifies if the camera uses a perspective or orthographic projection
  70696. */
  70697. type: CameraType;
  70698. }
  70699. /**
  70700. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70701. */
  70702. interface IImage extends IChildRootProperty {
  70703. /**
  70704. * 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
  70705. */
  70706. uri?: string;
  70707. /**
  70708. * The image's MIME type
  70709. */
  70710. mimeType?: ImageMimeType;
  70711. /**
  70712. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70713. */
  70714. bufferView?: number;
  70715. }
  70716. /**
  70717. * Material Normal Texture Info
  70718. */
  70719. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70720. /**
  70721. * The scalar multiplier applied to each normal vector of the normal texture
  70722. */
  70723. scale?: number;
  70724. }
  70725. /**
  70726. * Material Occlusion Texture Info
  70727. */
  70728. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70729. /**
  70730. * A scalar multiplier controlling the amount of occlusion applied
  70731. */
  70732. strength?: number;
  70733. }
  70734. /**
  70735. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70736. */
  70737. interface IMaterialPbrMetallicRoughness {
  70738. /**
  70739. * The material's base color factor
  70740. */
  70741. baseColorFactor?: number[];
  70742. /**
  70743. * The base color texture
  70744. */
  70745. baseColorTexture?: ITextureInfo;
  70746. /**
  70747. * The metalness of the material
  70748. */
  70749. metallicFactor?: number;
  70750. /**
  70751. * The roughness of the material
  70752. */
  70753. roughnessFactor?: number;
  70754. /**
  70755. * The metallic-roughness texture
  70756. */
  70757. metallicRoughnessTexture?: ITextureInfo;
  70758. }
  70759. /**
  70760. * The material appearance of a primitive
  70761. */
  70762. interface IMaterial extends IChildRootProperty {
  70763. /**
  70764. * 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
  70765. */
  70766. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70767. /**
  70768. * The normal map texture
  70769. */
  70770. normalTexture?: IMaterialNormalTextureInfo;
  70771. /**
  70772. * The occlusion map texture
  70773. */
  70774. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70775. /**
  70776. * The emissive map texture
  70777. */
  70778. emissiveTexture?: ITextureInfo;
  70779. /**
  70780. * 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
  70781. */
  70782. emissiveFactor?: number[];
  70783. /**
  70784. * The alpha rendering mode of the material
  70785. */
  70786. alphaMode?: MaterialAlphaMode;
  70787. /**
  70788. * The alpha cutoff value of the material
  70789. */
  70790. alphaCutoff?: number;
  70791. /**
  70792. * Specifies whether the material is double sided
  70793. */
  70794. doubleSided?: boolean;
  70795. }
  70796. /**
  70797. * Geometry to be rendered with the given material
  70798. */
  70799. interface IMeshPrimitive extends IProperty {
  70800. /**
  70801. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70802. */
  70803. attributes: {
  70804. [name: string]: number;
  70805. };
  70806. /**
  70807. * The index of the accessor that contains the indices
  70808. */
  70809. indices?: number;
  70810. /**
  70811. * The index of the material to apply to this primitive when rendering
  70812. */
  70813. material?: number;
  70814. /**
  70815. * The type of primitives to render. All valid values correspond to WebGL enums
  70816. */
  70817. mode?: MeshPrimitiveMode;
  70818. /**
  70819. * 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
  70820. */
  70821. targets?: {
  70822. [name: string]: number;
  70823. }[];
  70824. }
  70825. /**
  70826. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70827. */
  70828. interface IMesh extends IChildRootProperty {
  70829. /**
  70830. * An array of primitives, each defining geometry to be rendered with a material
  70831. */
  70832. primitives: IMeshPrimitive[];
  70833. /**
  70834. * Array of weights to be applied to the Morph Targets
  70835. */
  70836. weights?: number[];
  70837. }
  70838. /**
  70839. * A node in the node hierarchy
  70840. */
  70841. interface INode extends IChildRootProperty {
  70842. /**
  70843. * The index of the camera referenced by this node
  70844. */
  70845. camera?: number;
  70846. /**
  70847. * The indices of this node's children
  70848. */
  70849. children?: number[];
  70850. /**
  70851. * The index of the skin referenced by this node
  70852. */
  70853. skin?: number;
  70854. /**
  70855. * A floating-point 4x4 transformation matrix stored in column-major order
  70856. */
  70857. matrix?: number[];
  70858. /**
  70859. * The index of the mesh in this node
  70860. */
  70861. mesh?: number;
  70862. /**
  70863. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70864. */
  70865. rotation?: number[];
  70866. /**
  70867. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70868. */
  70869. scale?: number[];
  70870. /**
  70871. * The node's translation along the x, y, and z axes
  70872. */
  70873. translation?: number[];
  70874. /**
  70875. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70876. */
  70877. weights?: number[];
  70878. }
  70879. /**
  70880. * Texture sampler properties for filtering and wrapping modes
  70881. */
  70882. interface ISampler extends IChildRootProperty {
  70883. /**
  70884. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70885. */
  70886. magFilter?: TextureMagFilter;
  70887. /**
  70888. * Minification filter. All valid values correspond to WebGL enums
  70889. */
  70890. minFilter?: TextureMinFilter;
  70891. /**
  70892. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70893. */
  70894. wrapS?: TextureWrapMode;
  70895. /**
  70896. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70897. */
  70898. wrapT?: TextureWrapMode;
  70899. }
  70900. /**
  70901. * The root nodes of a scene
  70902. */
  70903. interface IScene extends IChildRootProperty {
  70904. /**
  70905. * The indices of each root node
  70906. */
  70907. nodes: number[];
  70908. }
  70909. /**
  70910. * Joints and matrices defining a skin
  70911. */
  70912. interface ISkin extends IChildRootProperty {
  70913. /**
  70914. * 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
  70915. */
  70916. inverseBindMatrices?: number;
  70917. /**
  70918. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70919. */
  70920. skeleton?: number;
  70921. /**
  70922. * 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)
  70923. */
  70924. joints: number[];
  70925. }
  70926. /**
  70927. * A texture and its sampler
  70928. */
  70929. interface ITexture extends IChildRootProperty {
  70930. /**
  70931. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70932. */
  70933. sampler?: number;
  70934. /**
  70935. * The index of the image used by this texture
  70936. */
  70937. source: number;
  70938. }
  70939. /**
  70940. * Reference to a texture
  70941. */
  70942. interface ITextureInfo extends IProperty {
  70943. /**
  70944. * The index of the texture
  70945. */
  70946. index: number;
  70947. /**
  70948. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70949. */
  70950. texCoord?: number;
  70951. }
  70952. /**
  70953. * The root object for a glTF asset
  70954. */
  70955. interface IGLTF extends IProperty {
  70956. /**
  70957. * An array of accessors. An accessor is a typed view into a bufferView
  70958. */
  70959. accessors?: IAccessor[];
  70960. /**
  70961. * An array of keyframe animations
  70962. */
  70963. animations?: IAnimation[];
  70964. /**
  70965. * Metadata about the glTF asset
  70966. */
  70967. asset: IAsset;
  70968. /**
  70969. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70970. */
  70971. buffers?: IBuffer[];
  70972. /**
  70973. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70974. */
  70975. bufferViews?: IBufferView[];
  70976. /**
  70977. * An array of cameras
  70978. */
  70979. cameras?: ICamera[];
  70980. /**
  70981. * Names of glTF extensions used somewhere in this asset
  70982. */
  70983. extensionsUsed?: string[];
  70984. /**
  70985. * Names of glTF extensions required to properly load this asset
  70986. */
  70987. extensionsRequired?: string[];
  70988. /**
  70989. * An array of images. An image defines data used to create a texture
  70990. */
  70991. images?: IImage[];
  70992. /**
  70993. * An array of materials. A material defines the appearance of a primitive
  70994. */
  70995. materials?: IMaterial[];
  70996. /**
  70997. * An array of meshes. A mesh is a set of primitives to be rendered
  70998. */
  70999. meshes?: IMesh[];
  71000. /**
  71001. * An array of nodes
  71002. */
  71003. nodes?: INode[];
  71004. /**
  71005. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71006. */
  71007. samplers?: ISampler[];
  71008. /**
  71009. * The index of the default scene
  71010. */
  71011. scene?: number;
  71012. /**
  71013. * An array of scenes
  71014. */
  71015. scenes?: IScene[];
  71016. /**
  71017. * An array of skins. A skin is defined by joints and matrices
  71018. */
  71019. skins?: ISkin[];
  71020. /**
  71021. * An array of textures
  71022. */
  71023. textures?: ITexture[];
  71024. }
  71025. /**
  71026. * The glTF validation results
  71027. * @ignore
  71028. */
  71029. interface IGLTFValidationResults {
  71030. info: {
  71031. generator: string;
  71032. hasAnimations: boolean;
  71033. hasDefaultScene: boolean;
  71034. hasMaterials: boolean;
  71035. hasMorphTargets: boolean;
  71036. hasSkins: boolean;
  71037. hasTextures: boolean;
  71038. maxAttributesUsed: number;
  71039. primitivesCount: number
  71040. };
  71041. issues: {
  71042. messages: Array<string>;
  71043. numErrors: number;
  71044. numHints: number;
  71045. numInfos: number;
  71046. numWarnings: number;
  71047. truncated: boolean
  71048. };
  71049. mimeType: string;
  71050. uri: string;
  71051. validatedAt: string;
  71052. validatorVersion: string;
  71053. }
  71054. /**
  71055. * The glTF validation options
  71056. */
  71057. interface IGLTFValidationOptions {
  71058. /** Uri to use */
  71059. uri?: string;
  71060. /** Function used to load external resources */
  71061. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71062. /** Boolean indicating that we need to validate accessor data */
  71063. validateAccessorData?: boolean;
  71064. /** max number of issues allowed */
  71065. maxIssues?: number;
  71066. /** Ignored issues */
  71067. ignoredIssues?: Array<string>;
  71068. /** Value to override severy settings */
  71069. severityOverrides?: Object;
  71070. }
  71071. /**
  71072. * The glTF validator object
  71073. * @ignore
  71074. */
  71075. interface IGLTFValidator {
  71076. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71077. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71078. }
  71079. }
  71080. declare module BABYLON {
  71081. /** @hidden */
  71082. export var cellPixelShader: {
  71083. name: string;
  71084. shader: string;
  71085. };
  71086. }
  71087. declare module BABYLON {
  71088. /** @hidden */
  71089. export var cellVertexShader: {
  71090. name: string;
  71091. shader: string;
  71092. };
  71093. }
  71094. declare module BABYLON {
  71095. export class CellMaterial extends BABYLON.PushMaterial {
  71096. private _diffuseTexture;
  71097. diffuseTexture: BABYLON.BaseTexture;
  71098. diffuseColor: BABYLON.Color3;
  71099. _computeHighLevel: boolean;
  71100. computeHighLevel: boolean;
  71101. private _disableLighting;
  71102. disableLighting: boolean;
  71103. private _maxSimultaneousLights;
  71104. maxSimultaneousLights: number;
  71105. private _renderId;
  71106. constructor(name: string, scene: BABYLON.Scene);
  71107. needAlphaBlending(): boolean;
  71108. needAlphaTesting(): boolean;
  71109. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71110. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71111. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71112. getAnimatables(): BABYLON.IAnimatable[];
  71113. getActiveTextures(): BABYLON.BaseTexture[];
  71114. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71115. dispose(forceDisposeEffect?: boolean): void;
  71116. getClassName(): string;
  71117. clone(name: string): CellMaterial;
  71118. serialize(): any;
  71119. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71120. }
  71121. }
  71122. declare module BABYLON {
  71123. export class CustomShaderStructure {
  71124. FragmentStore: string;
  71125. VertexStore: string;
  71126. constructor();
  71127. }
  71128. export class ShaderSpecialParts {
  71129. constructor();
  71130. Fragment_Begin: string;
  71131. Fragment_Definitions: string;
  71132. Fragment_MainBegin: string;
  71133. Fragment_Custom_Diffuse: string;
  71134. Fragment_Before_Lights: string;
  71135. Fragment_Before_Fog: string;
  71136. Fragment_Custom_Alpha: string;
  71137. Fragment_Before_FragColor: string;
  71138. Vertex_Begin: string;
  71139. Vertex_Definitions: string;
  71140. Vertex_MainBegin: string;
  71141. Vertex_Before_PositionUpdated: string;
  71142. Vertex_Before_NormalUpdated: string;
  71143. Vertex_MainEnd: string;
  71144. }
  71145. export class CustomMaterial extends BABYLON.StandardMaterial {
  71146. static ShaderIndexer: number;
  71147. CustomParts: ShaderSpecialParts;
  71148. _isCreatedShader: boolean;
  71149. _createdShaderName: string;
  71150. _customUniform: string[];
  71151. _newUniforms: string[];
  71152. _newUniformInstances: any[];
  71153. _newSamplerInstances: BABYLON.Texture[];
  71154. FragmentShader: string;
  71155. VertexShader: string;
  71156. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71157. ReviewUniform(name: string, arr: string[]): string[];
  71158. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71159. constructor(name: string, scene: BABYLON.Scene);
  71160. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71161. Fragment_Begin(shaderPart: string): CustomMaterial;
  71162. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71163. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71164. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71165. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71166. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71167. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71168. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71169. Vertex_Begin(shaderPart: string): CustomMaterial;
  71170. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71171. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71172. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71173. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71174. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71175. }
  71176. }
  71177. declare module BABYLON {
  71178. export class ShaderAlebdoParts {
  71179. constructor();
  71180. Fragment_Begin: string;
  71181. Fragment_Definitions: string;
  71182. Fragment_MainBegin: string;
  71183. Fragment_Custom_Albedo: string;
  71184. Fragment_Before_Lights: string;
  71185. Fragment_Custom_MetallicRoughness: string;
  71186. Fragment_Custom_MicroSurface: string;
  71187. Fragment_Before_Fog: string;
  71188. Fragment_Custom_Alpha: string;
  71189. Fragment_Before_FragColor: string;
  71190. Vertex_Begin: string;
  71191. Vertex_Definitions: string;
  71192. Vertex_MainBegin: string;
  71193. Vertex_Before_PositionUpdated: string;
  71194. Vertex_Before_NormalUpdated: string;
  71195. Vertex_MainEnd: string;
  71196. }
  71197. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71198. static ShaderIndexer: number;
  71199. CustomParts: ShaderAlebdoParts;
  71200. _isCreatedShader: boolean;
  71201. _createdShaderName: string;
  71202. _customUniform: string[];
  71203. _newUniforms: string[];
  71204. _newUniformInstances: any[];
  71205. _newSamplerInstances: BABYLON.Texture[];
  71206. FragmentShader: string;
  71207. VertexShader: string;
  71208. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71209. ReviewUniform(name: string, arr: string[]): string[];
  71210. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71211. constructor(name: string, scene: BABYLON.Scene);
  71212. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71213. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71214. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71215. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71216. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71217. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71218. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71219. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71220. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71221. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71222. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71223. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71224. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71225. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71226. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71227. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71228. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71229. }
  71230. }
  71231. declare module BABYLON {
  71232. /** @hidden */
  71233. export var firePixelShader: {
  71234. name: string;
  71235. shader: string;
  71236. };
  71237. }
  71238. declare module BABYLON {
  71239. /** @hidden */
  71240. export var fireVertexShader: {
  71241. name: string;
  71242. shader: string;
  71243. };
  71244. }
  71245. declare module BABYLON {
  71246. export class FireMaterial extends BABYLON.PushMaterial {
  71247. private _diffuseTexture;
  71248. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71249. private _distortionTexture;
  71250. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71251. private _opacityTexture;
  71252. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71253. diffuseColor: BABYLON.Color3;
  71254. speed: number;
  71255. private _scaledDiffuse;
  71256. private _renderId;
  71257. private _lastTime;
  71258. constructor(name: string, scene: BABYLON.Scene);
  71259. needAlphaBlending(): boolean;
  71260. needAlphaTesting(): boolean;
  71261. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71262. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71263. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71264. getAnimatables(): BABYLON.IAnimatable[];
  71265. getActiveTextures(): BABYLON.BaseTexture[];
  71266. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71267. getClassName(): string;
  71268. dispose(forceDisposeEffect?: boolean): void;
  71269. clone(name: string): FireMaterial;
  71270. serialize(): any;
  71271. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71272. }
  71273. }
  71274. declare module BABYLON {
  71275. /** @hidden */
  71276. export var furPixelShader: {
  71277. name: string;
  71278. shader: string;
  71279. };
  71280. }
  71281. declare module BABYLON {
  71282. /** @hidden */
  71283. export var furVertexShader: {
  71284. name: string;
  71285. shader: string;
  71286. };
  71287. }
  71288. declare module BABYLON {
  71289. export class FurMaterial extends BABYLON.PushMaterial {
  71290. private _diffuseTexture;
  71291. diffuseTexture: BABYLON.BaseTexture;
  71292. private _heightTexture;
  71293. heightTexture: BABYLON.BaseTexture;
  71294. diffuseColor: BABYLON.Color3;
  71295. furLength: number;
  71296. furAngle: number;
  71297. furColor: BABYLON.Color3;
  71298. furOffset: number;
  71299. furSpacing: number;
  71300. furGravity: BABYLON.Vector3;
  71301. furSpeed: number;
  71302. furDensity: number;
  71303. furOcclusion: number;
  71304. furTexture: BABYLON.DynamicTexture;
  71305. private _disableLighting;
  71306. disableLighting: boolean;
  71307. private _maxSimultaneousLights;
  71308. maxSimultaneousLights: number;
  71309. highLevelFur: boolean;
  71310. _meshes: BABYLON.AbstractMesh[];
  71311. private _renderId;
  71312. private _furTime;
  71313. constructor(name: string, scene: BABYLON.Scene);
  71314. furTime: number;
  71315. needAlphaBlending(): boolean;
  71316. needAlphaTesting(): boolean;
  71317. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71318. updateFur(): void;
  71319. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71320. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71321. getAnimatables(): BABYLON.IAnimatable[];
  71322. getActiveTextures(): BABYLON.BaseTexture[];
  71323. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71324. dispose(forceDisposeEffect?: boolean): void;
  71325. clone(name: string): FurMaterial;
  71326. serialize(): any;
  71327. getClassName(): string;
  71328. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71329. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71330. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71331. }
  71332. }
  71333. declare module BABYLON {
  71334. /** @hidden */
  71335. export var gradientPixelShader: {
  71336. name: string;
  71337. shader: string;
  71338. };
  71339. }
  71340. declare module BABYLON {
  71341. /** @hidden */
  71342. export var gradientVertexShader: {
  71343. name: string;
  71344. shader: string;
  71345. };
  71346. }
  71347. declare module BABYLON {
  71348. export class GradientMaterial extends BABYLON.PushMaterial {
  71349. private _maxSimultaneousLights;
  71350. maxSimultaneousLights: number;
  71351. topColor: BABYLON.Color3;
  71352. topColorAlpha: number;
  71353. bottomColor: BABYLON.Color3;
  71354. bottomColorAlpha: number;
  71355. offset: number;
  71356. scale: number;
  71357. smoothness: number;
  71358. private _disableLighting;
  71359. disableLighting: boolean;
  71360. private _renderId;
  71361. constructor(name: string, scene: BABYLON.Scene);
  71362. needAlphaBlending(): boolean;
  71363. needAlphaTesting(): boolean;
  71364. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71365. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71366. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71367. getAnimatables(): BABYLON.IAnimatable[];
  71368. dispose(forceDisposeEffect?: boolean): void;
  71369. clone(name: string): GradientMaterial;
  71370. serialize(): any;
  71371. getClassName(): string;
  71372. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71373. }
  71374. }
  71375. declare module BABYLON {
  71376. /** @hidden */
  71377. export var gridPixelShader: {
  71378. name: string;
  71379. shader: string;
  71380. };
  71381. }
  71382. declare module BABYLON {
  71383. /** @hidden */
  71384. export var gridVertexShader: {
  71385. name: string;
  71386. shader: string;
  71387. };
  71388. }
  71389. declare module BABYLON {
  71390. /**
  71391. * The grid materials allows you to wrap any shape with a grid.
  71392. * Colors are customizable.
  71393. */
  71394. export class GridMaterial extends BABYLON.PushMaterial {
  71395. /**
  71396. * Main color of the grid (e.g. between lines)
  71397. */
  71398. mainColor: BABYLON.Color3;
  71399. /**
  71400. * Color of the grid lines.
  71401. */
  71402. lineColor: BABYLON.Color3;
  71403. /**
  71404. * The scale of the grid compared to unit.
  71405. */
  71406. gridRatio: number;
  71407. /**
  71408. * Allows setting an offset for the grid lines.
  71409. */
  71410. gridOffset: BABYLON.Vector3;
  71411. /**
  71412. * The frequency of thicker lines.
  71413. */
  71414. majorUnitFrequency: number;
  71415. /**
  71416. * The visibility of minor units in the grid.
  71417. */
  71418. minorUnitVisibility: number;
  71419. /**
  71420. * The grid opacity outside of the lines.
  71421. */
  71422. opacity: number;
  71423. /**
  71424. * Determine RBG output is premultiplied by alpha value.
  71425. */
  71426. preMultiplyAlpha: boolean;
  71427. private _opacityTexture;
  71428. opacityTexture: BABYLON.BaseTexture;
  71429. private _gridControl;
  71430. private _renderId;
  71431. /**
  71432. * constructor
  71433. * @param name The name given to the material in order to identify it afterwards.
  71434. * @param scene The scene the material is used in.
  71435. */
  71436. constructor(name: string, scene: BABYLON.Scene);
  71437. /**
  71438. * Returns wehter or not the grid requires alpha blending.
  71439. */
  71440. needAlphaBlending(): boolean;
  71441. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71442. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71443. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71444. /**
  71445. * Dispose the material and its associated resources.
  71446. * @param forceDisposeEffect will also dispose the used effect when true
  71447. */
  71448. dispose(forceDisposeEffect?: boolean): void;
  71449. clone(name: string): GridMaterial;
  71450. serialize(): any;
  71451. getClassName(): string;
  71452. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71453. }
  71454. }
  71455. declare module BABYLON {
  71456. /** @hidden */
  71457. export var lavaPixelShader: {
  71458. name: string;
  71459. shader: string;
  71460. };
  71461. }
  71462. declare module BABYLON {
  71463. /** @hidden */
  71464. export var lavaVertexShader: {
  71465. name: string;
  71466. shader: string;
  71467. };
  71468. }
  71469. declare module BABYLON {
  71470. export class LavaMaterial extends BABYLON.PushMaterial {
  71471. private _diffuseTexture;
  71472. diffuseTexture: BABYLON.BaseTexture;
  71473. noiseTexture: BABYLON.BaseTexture;
  71474. fogColor: BABYLON.Color3;
  71475. speed: number;
  71476. movingSpeed: number;
  71477. lowFrequencySpeed: number;
  71478. fogDensity: number;
  71479. private _lastTime;
  71480. diffuseColor: BABYLON.Color3;
  71481. private _disableLighting;
  71482. disableLighting: boolean;
  71483. private _unlit;
  71484. unlit: boolean;
  71485. private _maxSimultaneousLights;
  71486. maxSimultaneousLights: number;
  71487. private _scaledDiffuse;
  71488. private _renderId;
  71489. constructor(name: string, scene: BABYLON.Scene);
  71490. needAlphaBlending(): boolean;
  71491. needAlphaTesting(): boolean;
  71492. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71493. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71494. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71495. getAnimatables(): BABYLON.IAnimatable[];
  71496. getActiveTextures(): BABYLON.BaseTexture[];
  71497. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71498. dispose(forceDisposeEffect?: boolean): void;
  71499. clone(name: string): LavaMaterial;
  71500. serialize(): any;
  71501. getClassName(): string;
  71502. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71503. }
  71504. }
  71505. declare module BABYLON {
  71506. /** @hidden */
  71507. export var mixPixelShader: {
  71508. name: string;
  71509. shader: string;
  71510. };
  71511. }
  71512. declare module BABYLON {
  71513. /** @hidden */
  71514. export var mixVertexShader: {
  71515. name: string;
  71516. shader: string;
  71517. };
  71518. }
  71519. declare module BABYLON {
  71520. export class MixMaterial extends BABYLON.PushMaterial {
  71521. /**
  71522. * Mix textures
  71523. */
  71524. private _mixTexture1;
  71525. mixTexture1: BABYLON.BaseTexture;
  71526. private _mixTexture2;
  71527. mixTexture2: BABYLON.BaseTexture;
  71528. /**
  71529. * Diffuse textures
  71530. */
  71531. private _diffuseTexture1;
  71532. diffuseTexture1: BABYLON.Texture;
  71533. private _diffuseTexture2;
  71534. diffuseTexture2: BABYLON.Texture;
  71535. private _diffuseTexture3;
  71536. diffuseTexture3: BABYLON.Texture;
  71537. private _diffuseTexture4;
  71538. diffuseTexture4: BABYLON.Texture;
  71539. private _diffuseTexture5;
  71540. diffuseTexture5: BABYLON.Texture;
  71541. private _diffuseTexture6;
  71542. diffuseTexture6: BABYLON.Texture;
  71543. private _diffuseTexture7;
  71544. diffuseTexture7: BABYLON.Texture;
  71545. private _diffuseTexture8;
  71546. diffuseTexture8: BABYLON.Texture;
  71547. /**
  71548. * Uniforms
  71549. */
  71550. diffuseColor: BABYLON.Color3;
  71551. specularColor: BABYLON.Color3;
  71552. specularPower: number;
  71553. private _disableLighting;
  71554. disableLighting: boolean;
  71555. private _maxSimultaneousLights;
  71556. maxSimultaneousLights: number;
  71557. private _renderId;
  71558. constructor(name: string, scene: BABYLON.Scene);
  71559. needAlphaBlending(): boolean;
  71560. needAlphaTesting(): boolean;
  71561. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71564. getAnimatables(): BABYLON.IAnimatable[];
  71565. getActiveTextures(): BABYLON.BaseTexture[];
  71566. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71567. dispose(forceDisposeEffect?: boolean): void;
  71568. clone(name: string): MixMaterial;
  71569. serialize(): any;
  71570. getClassName(): string;
  71571. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71572. }
  71573. }
  71574. declare module BABYLON {
  71575. /** @hidden */
  71576. export var normalPixelShader: {
  71577. name: string;
  71578. shader: string;
  71579. };
  71580. }
  71581. declare module BABYLON {
  71582. /** @hidden */
  71583. export var normalVertexShader: {
  71584. name: string;
  71585. shader: string;
  71586. };
  71587. }
  71588. declare module BABYLON {
  71589. export class NormalMaterial extends BABYLON.PushMaterial {
  71590. private _diffuseTexture;
  71591. diffuseTexture: BABYLON.BaseTexture;
  71592. diffuseColor: BABYLON.Color3;
  71593. private _disableLighting;
  71594. disableLighting: boolean;
  71595. private _maxSimultaneousLights;
  71596. maxSimultaneousLights: number;
  71597. private _renderId;
  71598. constructor(name: string, scene: BABYLON.Scene);
  71599. needAlphaBlending(): boolean;
  71600. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71601. needAlphaTesting(): boolean;
  71602. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71603. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71604. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71605. getAnimatables(): BABYLON.IAnimatable[];
  71606. getActiveTextures(): BABYLON.BaseTexture[];
  71607. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71608. dispose(forceDisposeEffect?: boolean): void;
  71609. clone(name: string): NormalMaterial;
  71610. serialize(): any;
  71611. getClassName(): string;
  71612. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71613. }
  71614. }
  71615. declare module BABYLON {
  71616. /** @hidden */
  71617. export var shadowOnlyPixelShader: {
  71618. name: string;
  71619. shader: string;
  71620. };
  71621. }
  71622. declare module BABYLON {
  71623. /** @hidden */
  71624. export var shadowOnlyVertexShader: {
  71625. name: string;
  71626. shader: string;
  71627. };
  71628. }
  71629. declare module BABYLON {
  71630. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71631. private _renderId;
  71632. private _activeLight;
  71633. constructor(name: string, scene: BABYLON.Scene);
  71634. shadowColor: BABYLON.Color3;
  71635. needAlphaBlending(): boolean;
  71636. needAlphaTesting(): boolean;
  71637. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71638. activeLight: BABYLON.IShadowLight;
  71639. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71640. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71641. clone(name: string): ShadowOnlyMaterial;
  71642. serialize(): any;
  71643. getClassName(): string;
  71644. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71645. }
  71646. }
  71647. declare module BABYLON {
  71648. /** @hidden */
  71649. export var simplePixelShader: {
  71650. name: string;
  71651. shader: string;
  71652. };
  71653. }
  71654. declare module BABYLON {
  71655. /** @hidden */
  71656. export var simpleVertexShader: {
  71657. name: string;
  71658. shader: string;
  71659. };
  71660. }
  71661. declare module BABYLON {
  71662. export class SimpleMaterial extends BABYLON.PushMaterial {
  71663. private _diffuseTexture;
  71664. diffuseTexture: BABYLON.BaseTexture;
  71665. diffuseColor: BABYLON.Color3;
  71666. private _disableLighting;
  71667. disableLighting: boolean;
  71668. private _maxSimultaneousLights;
  71669. maxSimultaneousLights: number;
  71670. private _renderId;
  71671. constructor(name: string, scene: BABYLON.Scene);
  71672. needAlphaBlending(): boolean;
  71673. needAlphaTesting(): boolean;
  71674. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71675. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71676. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71677. getAnimatables(): BABYLON.IAnimatable[];
  71678. getActiveTextures(): BABYLON.BaseTexture[];
  71679. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71680. dispose(forceDisposeEffect?: boolean): void;
  71681. clone(name: string): SimpleMaterial;
  71682. serialize(): any;
  71683. getClassName(): string;
  71684. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71685. }
  71686. }
  71687. declare module BABYLON {
  71688. /** @hidden */
  71689. export var skyPixelShader: {
  71690. name: string;
  71691. shader: string;
  71692. };
  71693. }
  71694. declare module BABYLON {
  71695. /** @hidden */
  71696. export var skyVertexShader: {
  71697. name: string;
  71698. shader: string;
  71699. };
  71700. }
  71701. declare module BABYLON {
  71702. /**
  71703. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71704. * @see https://doc.babylonjs.com/extensions/sky
  71705. */
  71706. export class SkyMaterial extends BABYLON.PushMaterial {
  71707. /**
  71708. * Defines the overall luminance of sky in interval ]0, 1[.
  71709. */
  71710. luminance: number;
  71711. /**
  71712. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71713. */
  71714. turbidity: number;
  71715. /**
  71716. * Defines the sky appearance (light intensity).
  71717. */
  71718. rayleigh: number;
  71719. /**
  71720. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71721. */
  71722. mieCoefficient: number;
  71723. /**
  71724. * Defines the amount of haze particles following the Mie scattering theory.
  71725. */
  71726. mieDirectionalG: number;
  71727. /**
  71728. * Defines the distance of the sun according to the active scene camera.
  71729. */
  71730. distance: number;
  71731. /**
  71732. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71733. * "inclined".
  71734. */
  71735. inclination: number;
  71736. /**
  71737. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71738. * an object direction and a reference direction.
  71739. */
  71740. azimuth: number;
  71741. /**
  71742. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71743. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71744. */
  71745. sunPosition: BABYLON.Vector3;
  71746. /**
  71747. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71748. * .sunPosition property.
  71749. */
  71750. useSunPosition: boolean;
  71751. /**
  71752. * Defines an offset vector used to get a horizon offset.
  71753. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71754. */
  71755. cameraOffset: BABYLON.Vector3;
  71756. private _cameraPosition;
  71757. private _renderId;
  71758. /**
  71759. * Instantiates a new sky material.
  71760. * This material allows to create dynamic and texture free
  71761. * effects for skyboxes by taking care of the atmosphere state.
  71762. * @see https://doc.babylonjs.com/extensions/sky
  71763. * @param name Define the name of the material in the scene
  71764. * @param scene Define the scene the material belong to
  71765. */
  71766. constructor(name: string, scene: BABYLON.Scene);
  71767. /**
  71768. * Specifies if the material will require alpha blending
  71769. * @returns a boolean specifying if alpha blending is needed
  71770. */
  71771. needAlphaBlending(): boolean;
  71772. /**
  71773. * Specifies if this material should be rendered in alpha test mode
  71774. * @returns false as the sky material doesn't need alpha testing.
  71775. */
  71776. needAlphaTesting(): boolean;
  71777. /**
  71778. * Get the texture used for alpha test purpose.
  71779. * @returns null as the sky material has no texture.
  71780. */
  71781. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71782. /**
  71783. * Get if the submesh is ready to be used and all its information available.
  71784. * Child classes can use it to update shaders
  71785. * @param mesh defines the mesh to check
  71786. * @param subMesh defines which submesh to check
  71787. * @param useInstances specifies that instances should be used
  71788. * @returns a boolean indicating that the submesh is ready or not
  71789. */
  71790. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71791. /**
  71792. * Binds the submesh to this material by preparing the effect and shader to draw
  71793. * @param world defines the world transformation matrix
  71794. * @param mesh defines the mesh containing the submesh
  71795. * @param subMesh defines the submesh to bind the material to
  71796. */
  71797. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71798. /**
  71799. * Get the list of animatables in the material.
  71800. * @returns the list of animatables object used in the material
  71801. */
  71802. getAnimatables(): BABYLON.IAnimatable[];
  71803. /**
  71804. * Disposes the material
  71805. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71806. */
  71807. dispose(forceDisposeEffect?: boolean): void;
  71808. /**
  71809. * Makes a duplicate of the material, and gives it a new name
  71810. * @param name defines the new name for the duplicated material
  71811. * @returns the cloned material
  71812. */
  71813. clone(name: string): SkyMaterial;
  71814. /**
  71815. * Serializes this material in a JSON representation
  71816. * @returns the serialized material object
  71817. */
  71818. serialize(): any;
  71819. /**
  71820. * Gets the current class name of the material e.g. "SkyMaterial"
  71821. * Mainly use in serialization.
  71822. * @returns the class name
  71823. */
  71824. getClassName(): string;
  71825. /**
  71826. * Creates a sky material from parsed material data
  71827. * @param source defines the JSON representation of the material
  71828. * @param scene defines the hosting scene
  71829. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71830. * @returns a new sky material
  71831. */
  71832. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71833. }
  71834. }
  71835. declare module BABYLON {
  71836. /** @hidden */
  71837. export var terrainPixelShader: {
  71838. name: string;
  71839. shader: string;
  71840. };
  71841. }
  71842. declare module BABYLON {
  71843. /** @hidden */
  71844. export var terrainVertexShader: {
  71845. name: string;
  71846. shader: string;
  71847. };
  71848. }
  71849. declare module BABYLON {
  71850. export class TerrainMaterial extends BABYLON.PushMaterial {
  71851. private _mixTexture;
  71852. mixTexture: BABYLON.BaseTexture;
  71853. private _diffuseTexture1;
  71854. diffuseTexture1: BABYLON.Texture;
  71855. private _diffuseTexture2;
  71856. diffuseTexture2: BABYLON.Texture;
  71857. private _diffuseTexture3;
  71858. diffuseTexture3: BABYLON.Texture;
  71859. private _bumpTexture1;
  71860. bumpTexture1: BABYLON.Texture;
  71861. private _bumpTexture2;
  71862. bumpTexture2: BABYLON.Texture;
  71863. private _bumpTexture3;
  71864. bumpTexture3: BABYLON.Texture;
  71865. diffuseColor: BABYLON.Color3;
  71866. specularColor: BABYLON.Color3;
  71867. specularPower: number;
  71868. private _disableLighting;
  71869. disableLighting: boolean;
  71870. private _maxSimultaneousLights;
  71871. maxSimultaneousLights: number;
  71872. private _renderId;
  71873. constructor(name: string, scene: BABYLON.Scene);
  71874. needAlphaBlending(): boolean;
  71875. needAlphaTesting(): boolean;
  71876. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71877. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71878. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71879. getAnimatables(): BABYLON.IAnimatable[];
  71880. getActiveTextures(): BABYLON.BaseTexture[];
  71881. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71882. dispose(forceDisposeEffect?: boolean): void;
  71883. clone(name: string): TerrainMaterial;
  71884. serialize(): any;
  71885. getClassName(): string;
  71886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71887. }
  71888. }
  71889. declare module BABYLON {
  71890. /** @hidden */
  71891. export var triplanarPixelShader: {
  71892. name: string;
  71893. shader: string;
  71894. };
  71895. }
  71896. declare module BABYLON {
  71897. /** @hidden */
  71898. export var triplanarVertexShader: {
  71899. name: string;
  71900. shader: string;
  71901. };
  71902. }
  71903. declare module BABYLON {
  71904. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71905. mixTexture: BABYLON.BaseTexture;
  71906. private _diffuseTextureX;
  71907. diffuseTextureX: BABYLON.BaseTexture;
  71908. private _diffuseTextureY;
  71909. diffuseTextureY: BABYLON.BaseTexture;
  71910. private _diffuseTextureZ;
  71911. diffuseTextureZ: BABYLON.BaseTexture;
  71912. private _normalTextureX;
  71913. normalTextureX: BABYLON.BaseTexture;
  71914. private _normalTextureY;
  71915. normalTextureY: BABYLON.BaseTexture;
  71916. private _normalTextureZ;
  71917. normalTextureZ: BABYLON.BaseTexture;
  71918. tileSize: number;
  71919. diffuseColor: BABYLON.Color3;
  71920. specularColor: BABYLON.Color3;
  71921. specularPower: number;
  71922. private _disableLighting;
  71923. disableLighting: boolean;
  71924. private _maxSimultaneousLights;
  71925. maxSimultaneousLights: number;
  71926. private _renderId;
  71927. constructor(name: string, scene: BABYLON.Scene);
  71928. needAlphaBlending(): boolean;
  71929. needAlphaTesting(): boolean;
  71930. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71931. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71932. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71933. getAnimatables(): BABYLON.IAnimatable[];
  71934. getActiveTextures(): BABYLON.BaseTexture[];
  71935. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71936. dispose(forceDisposeEffect?: boolean): void;
  71937. clone(name: string): TriPlanarMaterial;
  71938. serialize(): any;
  71939. getClassName(): string;
  71940. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71941. }
  71942. }
  71943. declare module BABYLON {
  71944. /** @hidden */
  71945. export var waterPixelShader: {
  71946. name: string;
  71947. shader: string;
  71948. };
  71949. }
  71950. declare module BABYLON {
  71951. /** @hidden */
  71952. export var waterVertexShader: {
  71953. name: string;
  71954. shader: string;
  71955. };
  71956. }
  71957. declare module BABYLON {
  71958. export class WaterMaterial extends BABYLON.PushMaterial {
  71959. renderTargetSize: BABYLON.Vector2;
  71960. private _bumpTexture;
  71961. bumpTexture: BABYLON.BaseTexture;
  71962. diffuseColor: BABYLON.Color3;
  71963. specularColor: BABYLON.Color3;
  71964. specularPower: number;
  71965. private _disableLighting;
  71966. disableLighting: boolean;
  71967. private _maxSimultaneousLights;
  71968. maxSimultaneousLights: number;
  71969. /**
  71970. * @param {number}: Represents the wind force
  71971. */
  71972. windForce: number;
  71973. /**
  71974. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71975. */
  71976. windDirection: BABYLON.Vector2;
  71977. /**
  71978. * @param {number}: Wave height, represents the height of the waves
  71979. */
  71980. waveHeight: number;
  71981. /**
  71982. * @param {number}: Bump height, represents the bump height related to the bump map
  71983. */
  71984. bumpHeight: number;
  71985. /**
  71986. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71987. */
  71988. private _bumpSuperimpose;
  71989. bumpSuperimpose: boolean;
  71990. /**
  71991. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71992. */
  71993. private _fresnelSeparate;
  71994. fresnelSeparate: boolean;
  71995. /**
  71996. * @param {boolean}: bump Waves modify the reflection.
  71997. */
  71998. private _bumpAffectsReflection;
  71999. bumpAffectsReflection: boolean;
  72000. /**
  72001. * @param {number}: The water color blended with the refraction (near)
  72002. */
  72003. waterColor: BABYLON.Color3;
  72004. /**
  72005. * @param {number}: The blend factor related to the water color
  72006. */
  72007. colorBlendFactor: number;
  72008. /**
  72009. * @param {number}: The water color blended with the reflection (far)
  72010. */
  72011. waterColor2: BABYLON.Color3;
  72012. /**
  72013. * @param {number}: The blend factor related to the water color (reflection, far)
  72014. */
  72015. colorBlendFactor2: number;
  72016. /**
  72017. * @param {number}: Represents the maximum length of a wave
  72018. */
  72019. waveLength: number;
  72020. /**
  72021. * @param {number}: Defines the waves speed
  72022. */
  72023. waveSpeed: number;
  72024. /**
  72025. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72026. * will avoid calculating useless pixels in the pixel shader of the water material.
  72027. */
  72028. disableClipPlane: boolean;
  72029. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72030. private _mesh;
  72031. private _refractionRTT;
  72032. private _reflectionRTT;
  72033. private _reflectionTransform;
  72034. private _lastTime;
  72035. private _lastDeltaTime;
  72036. private _renderId;
  72037. private _useLogarithmicDepth;
  72038. private _waitingRenderList;
  72039. private _imageProcessingConfiguration;
  72040. private _imageProcessingObserver;
  72041. /**
  72042. * Gets a boolean indicating that current material needs to register RTT
  72043. */
  72044. readonly hasRenderTargetTextures: boolean;
  72045. /**
  72046. * Constructor
  72047. */
  72048. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72049. useLogarithmicDepth: boolean;
  72050. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72051. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72052. addToRenderList(node: any): void;
  72053. enableRenderTargets(enable: boolean): void;
  72054. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72055. readonly renderTargetsEnabled: boolean;
  72056. needAlphaBlending(): boolean;
  72057. needAlphaTesting(): boolean;
  72058. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72059. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72060. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72061. private _createRenderTargets;
  72062. getAnimatables(): BABYLON.IAnimatable[];
  72063. getActiveTextures(): BABYLON.BaseTexture[];
  72064. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72065. dispose(forceDisposeEffect?: boolean): void;
  72066. clone(name: string): WaterMaterial;
  72067. serialize(): any;
  72068. getClassName(): string;
  72069. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72070. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72071. }
  72072. }
  72073. declare module BABYLON {
  72074. /** @hidden */
  72075. export var asciiartPixelShader: {
  72076. name: string;
  72077. shader: string;
  72078. };
  72079. }
  72080. declare module BABYLON {
  72081. /**
  72082. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72083. *
  72084. * It basically takes care rendering the font front the given font size to a texture.
  72085. * This is used later on in the postprocess.
  72086. */
  72087. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72088. private _font;
  72089. private _text;
  72090. private _charSize;
  72091. /**
  72092. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72093. */
  72094. readonly charSize: number;
  72095. /**
  72096. * Create a new instance of the Ascii Art FontTexture class
  72097. * @param name the name of the texture
  72098. * @param font the font to use, use the W3C CSS notation
  72099. * @param text the caracter set to use in the rendering.
  72100. * @param scene the scene that owns the texture
  72101. */
  72102. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72103. /**
  72104. * Gets the max char width of a font.
  72105. * @param font the font to use, use the W3C CSS notation
  72106. * @return the max char width
  72107. */
  72108. private getFontWidth;
  72109. /**
  72110. * Gets the max char height of a font.
  72111. * @param font the font to use, use the W3C CSS notation
  72112. * @return the max char height
  72113. */
  72114. private getFontHeight;
  72115. /**
  72116. * Clones the current AsciiArtTexture.
  72117. * @return the clone of the texture.
  72118. */
  72119. clone(): AsciiArtFontTexture;
  72120. /**
  72121. * Parses a json object representing the texture and returns an instance of it.
  72122. * @param source the source JSON representation
  72123. * @param scene the scene to create the texture for
  72124. * @return the parsed texture
  72125. */
  72126. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72127. }
  72128. /**
  72129. * Option available in the Ascii Art Post Process.
  72130. */
  72131. export interface IAsciiArtPostProcessOptions {
  72132. /**
  72133. * The font to use following the w3c font definition.
  72134. */
  72135. font?: string;
  72136. /**
  72137. * The character set to use in the postprocess.
  72138. */
  72139. characterSet?: string;
  72140. /**
  72141. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72142. * This number is defined between 0 and 1;
  72143. */
  72144. mixToTile?: number;
  72145. /**
  72146. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72147. * This number is defined between 0 and 1;
  72148. */
  72149. mixToNormal?: number;
  72150. }
  72151. /**
  72152. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72153. *
  72154. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72155. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72156. */
  72157. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72158. /**
  72159. * The font texture used to render the char in the post process.
  72160. */
  72161. private _asciiArtFontTexture;
  72162. /**
  72163. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72164. * This number is defined between 0 and 1;
  72165. */
  72166. mixToTile: number;
  72167. /**
  72168. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72169. * This number is defined between 0 and 1;
  72170. */
  72171. mixToNormal: number;
  72172. /**
  72173. * Instantiates a new Ascii Art Post Process.
  72174. * @param name the name to give to the postprocess
  72175. * @camera the camera to apply the post process to.
  72176. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72177. */
  72178. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72179. }
  72180. }
  72181. declare module BABYLON {
  72182. /** @hidden */
  72183. export var digitalrainPixelShader: {
  72184. name: string;
  72185. shader: string;
  72186. };
  72187. }
  72188. declare module BABYLON {
  72189. /**
  72190. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72191. *
  72192. * It basically takes care rendering the font front the given font size to a texture.
  72193. * This is used later on in the postprocess.
  72194. */
  72195. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72196. private _font;
  72197. private _text;
  72198. private _charSize;
  72199. /**
  72200. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72201. */
  72202. readonly charSize: number;
  72203. /**
  72204. * Create a new instance of the Digital Rain FontTexture class
  72205. * @param name the name of the texture
  72206. * @param font the font to use, use the W3C CSS notation
  72207. * @param text the caracter set to use in the rendering.
  72208. * @param scene the scene that owns the texture
  72209. */
  72210. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72211. /**
  72212. * Gets the max char width of a font.
  72213. * @param font the font to use, use the W3C CSS notation
  72214. * @return the max char width
  72215. */
  72216. private getFontWidth;
  72217. /**
  72218. * Gets the max char height of a font.
  72219. * @param font the font to use, use the W3C CSS notation
  72220. * @return the max char height
  72221. */
  72222. private getFontHeight;
  72223. /**
  72224. * Clones the current DigitalRainFontTexture.
  72225. * @return the clone of the texture.
  72226. */
  72227. clone(): DigitalRainFontTexture;
  72228. /**
  72229. * Parses a json object representing the texture and returns an instance of it.
  72230. * @param source the source JSON representation
  72231. * @param scene the scene to create the texture for
  72232. * @return the parsed texture
  72233. */
  72234. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72235. }
  72236. /**
  72237. * Option available in the Digital Rain Post Process.
  72238. */
  72239. export interface IDigitalRainPostProcessOptions {
  72240. /**
  72241. * The font to use following the w3c font definition.
  72242. */
  72243. font?: string;
  72244. /**
  72245. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72246. * This number is defined between 0 and 1;
  72247. */
  72248. mixToTile?: number;
  72249. /**
  72250. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72251. * This number is defined between 0 and 1;
  72252. */
  72253. mixToNormal?: number;
  72254. }
  72255. /**
  72256. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72257. *
  72258. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72259. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72260. */
  72261. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72262. /**
  72263. * The font texture used to render the char in the post process.
  72264. */
  72265. private _digitalRainFontTexture;
  72266. /**
  72267. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72268. * This number is defined between 0 and 1;
  72269. */
  72270. mixToTile: number;
  72271. /**
  72272. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72273. * This number is defined between 0 and 1;
  72274. */
  72275. mixToNormal: number;
  72276. /**
  72277. * Instantiates a new Digital Rain Post Process.
  72278. * @param name the name to give to the postprocess
  72279. * @camera the camera to apply the post process to.
  72280. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72281. */
  72282. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72283. }
  72284. }
  72285. declare module BABYLON {
  72286. /** @hidden */
  72287. export var oceanPostProcessPixelShader: {
  72288. name: string;
  72289. shader: string;
  72290. };
  72291. }
  72292. declare module BABYLON {
  72293. /**
  72294. * Option available in the Ocean Post Process.
  72295. */
  72296. export interface IOceanPostProcessOptions {
  72297. /**
  72298. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72299. */
  72300. reflectionSize?: number | {
  72301. width: number;
  72302. height: number;
  72303. } | {
  72304. ratio: number;
  72305. };
  72306. /**
  72307. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72308. */
  72309. refractionSize?: number | {
  72310. width: number;
  72311. height: number;
  72312. } | {
  72313. ratio: number;
  72314. };
  72315. }
  72316. /**
  72317. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72318. *
  72319. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72320. * Example usage:
  72321. * var pp = new OceanPostProcess("myOcean", camera);
  72322. * pp.reflectionEnabled = true;
  72323. * pp.refractionEnabled = true;
  72324. */
  72325. export class OceanPostProcess extends BABYLON.PostProcess {
  72326. /**
  72327. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72328. */
  72329. /**
  72330. * Sets weither or not the real-time reflection is enabled on the ocean.
  72331. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72332. */
  72333. reflectionEnabled: boolean;
  72334. /**
  72335. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72336. */
  72337. /**
  72338. * Sets weither or not the real-time refraction is enabled on the ocean.
  72339. * Is set to true, the refraction render target texture will be used as refraction texture.
  72340. */
  72341. refractionEnabled: boolean;
  72342. /**
  72343. * Gets wether or not the post-processes is supported by the running hardware.
  72344. * This requires draw buffer supports.
  72345. */
  72346. readonly isSupported: boolean;
  72347. /**
  72348. * This is the reflection mirror texture used to display reflections on the ocean.
  72349. * By default, render list is empty.
  72350. */
  72351. reflectionTexture: BABYLON.MirrorTexture;
  72352. /**
  72353. * This is the refraction render target texture used to display refraction on the ocean.
  72354. * By default, render list is empty.
  72355. */
  72356. refractionTexture: BABYLON.RenderTargetTexture;
  72357. private _time;
  72358. private _cameraRotation;
  72359. private _cameraViewMatrix;
  72360. private _reflectionEnabled;
  72361. private _refractionEnabled;
  72362. private _geometryRenderer;
  72363. /**
  72364. * Instantiates a new Ocean Post Process.
  72365. * @param name the name to give to the postprocess.
  72366. * @camera the camera to apply the post process to.
  72367. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72368. */
  72369. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72370. /**
  72371. * Returns the appropriate defines according to the current configuration.
  72372. */
  72373. private _getDefines;
  72374. /**
  72375. * Computes the current camera rotation as the shader requires a camera rotation.
  72376. */
  72377. private _computeCameraRotation;
  72378. }
  72379. }
  72380. declare module BABYLON {
  72381. /** @hidden */
  72382. export var brickProceduralTexturePixelShader: {
  72383. name: string;
  72384. shader: string;
  72385. };
  72386. }
  72387. declare module BABYLON {
  72388. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72389. private _numberOfBricksHeight;
  72390. private _numberOfBricksWidth;
  72391. private _jointColor;
  72392. private _brickColor;
  72393. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72394. updateShaderUniforms(): void;
  72395. numberOfBricksHeight: number;
  72396. numberOfBricksWidth: number;
  72397. jointColor: BABYLON.Color3;
  72398. brickColor: BABYLON.Color3;
  72399. /**
  72400. * Serializes this brick procedural texture
  72401. * @returns a serialized brick procedural texture object
  72402. */
  72403. serialize(): any;
  72404. /**
  72405. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72406. * @param parsedTexture defines parsed texture data
  72407. * @param scene defines the current scene
  72408. * @param rootUrl defines the root URL containing brick procedural texture information
  72409. * @returns a parsed Brick Procedural BABYLON.Texture
  72410. */
  72411. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72412. }
  72413. }
  72414. declare module BABYLON {
  72415. /** @hidden */
  72416. export var cloudProceduralTexturePixelShader: {
  72417. name: string;
  72418. shader: string;
  72419. };
  72420. }
  72421. declare module BABYLON {
  72422. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72423. private _skyColor;
  72424. private _cloudColor;
  72425. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72426. updateShaderUniforms(): void;
  72427. skyColor: BABYLON.Color4;
  72428. cloudColor: BABYLON.Color4;
  72429. /**
  72430. * Serializes this cloud procedural texture
  72431. * @returns a serialized cloud procedural texture object
  72432. */
  72433. serialize(): any;
  72434. /**
  72435. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72436. * @param parsedTexture defines parsed texture data
  72437. * @param scene defines the current scene
  72438. * @param rootUrl defines the root URL containing cloud procedural texture information
  72439. * @returns a parsed Cloud Procedural BABYLON.Texture
  72440. */
  72441. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72442. }
  72443. }
  72444. declare module BABYLON {
  72445. /** @hidden */
  72446. export var fireProceduralTexturePixelShader: {
  72447. name: string;
  72448. shader: string;
  72449. };
  72450. }
  72451. declare module BABYLON {
  72452. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72453. private _time;
  72454. private _speed;
  72455. private _autoGenerateTime;
  72456. private _fireColors;
  72457. private _alphaThreshold;
  72458. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72459. updateShaderUniforms(): void;
  72460. render(useCameraPostProcess?: boolean): void;
  72461. static readonly PurpleFireColors: BABYLON.Color3[];
  72462. static readonly GreenFireColors: BABYLON.Color3[];
  72463. static readonly RedFireColors: BABYLON.Color3[];
  72464. static readonly BlueFireColors: BABYLON.Color3[];
  72465. autoGenerateTime: boolean;
  72466. fireColors: BABYLON.Color3[];
  72467. time: number;
  72468. speed: BABYLON.Vector2;
  72469. alphaThreshold: number;
  72470. /**
  72471. * Serializes this fire procedural texture
  72472. * @returns a serialized fire procedural texture object
  72473. */
  72474. serialize(): any;
  72475. /**
  72476. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72477. * @param parsedTexture defines parsed texture data
  72478. * @param scene defines the current scene
  72479. * @param rootUrl defines the root URL containing fire procedural texture information
  72480. * @returns a parsed Fire Procedural BABYLON.Texture
  72481. */
  72482. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72483. }
  72484. }
  72485. declare module BABYLON {
  72486. /** @hidden */
  72487. export var grassProceduralTexturePixelShader: {
  72488. name: string;
  72489. shader: string;
  72490. };
  72491. }
  72492. declare module BABYLON {
  72493. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72494. private _grassColors;
  72495. private _groundColor;
  72496. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72497. updateShaderUniforms(): void;
  72498. grassColors: BABYLON.Color3[];
  72499. groundColor: BABYLON.Color3;
  72500. /**
  72501. * Serializes this grass procedural texture
  72502. * @returns a serialized grass procedural texture object
  72503. */
  72504. serialize(): any;
  72505. /**
  72506. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72507. * @param parsedTexture defines parsed texture data
  72508. * @param scene defines the current scene
  72509. * @param rootUrl defines the root URL containing grass procedural texture information
  72510. * @returns a parsed Grass Procedural BABYLON.Texture
  72511. */
  72512. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72513. }
  72514. }
  72515. declare module BABYLON {
  72516. /** @hidden */
  72517. export var marbleProceduralTexturePixelShader: {
  72518. name: string;
  72519. shader: string;
  72520. };
  72521. }
  72522. declare module BABYLON {
  72523. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72524. private _numberOfTilesHeight;
  72525. private _numberOfTilesWidth;
  72526. private _amplitude;
  72527. private _jointColor;
  72528. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72529. updateShaderUniforms(): void;
  72530. numberOfTilesHeight: number;
  72531. amplitude: number;
  72532. numberOfTilesWidth: number;
  72533. jointColor: BABYLON.Color3;
  72534. /**
  72535. * Serializes this marble procedural texture
  72536. * @returns a serialized marble procedural texture object
  72537. */
  72538. serialize(): any;
  72539. /**
  72540. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72541. * @param parsedTexture defines parsed texture data
  72542. * @param scene defines the current scene
  72543. * @param rootUrl defines the root URL containing marble procedural texture information
  72544. * @returns a parsed Marble Procedural BABYLON.Texture
  72545. */
  72546. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72547. }
  72548. }
  72549. declare module BABYLON {
  72550. /** @hidden */
  72551. export var normalMapProceduralTexturePixelShader: {
  72552. name: string;
  72553. shader: string;
  72554. };
  72555. }
  72556. declare module BABYLON {
  72557. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72558. private _baseTexture;
  72559. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72560. updateShaderUniforms(): void;
  72561. render(useCameraPostProcess?: boolean): void;
  72562. resize(size: any, generateMipMaps: any): void;
  72563. baseTexture: BABYLON.Texture;
  72564. /**
  72565. * Serializes this normal map procedural texture
  72566. * @returns a serialized normal map procedural texture object
  72567. */
  72568. serialize(): any;
  72569. /**
  72570. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72571. * @param parsedTexture defines parsed texture data
  72572. * @param scene defines the current scene
  72573. * @param rootUrl defines the root URL containing normal map procedural texture information
  72574. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72575. */
  72576. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72577. }
  72578. }
  72579. declare module BABYLON {
  72580. /** @hidden */
  72581. export var perlinNoiseProceduralTexturePixelShader: {
  72582. name: string;
  72583. shader: string;
  72584. };
  72585. }
  72586. declare module BABYLON {
  72587. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72588. time: number;
  72589. timeScale: number;
  72590. translationSpeed: number;
  72591. private _currentTranslation;
  72592. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72593. updateShaderUniforms(): void;
  72594. render(useCameraPostProcess?: boolean): void;
  72595. resize(size: any, generateMipMaps: any): void;
  72596. /**
  72597. * Serializes this perlin noise procedural texture
  72598. * @returns a serialized perlin noise procedural texture object
  72599. */
  72600. serialize(): any;
  72601. /**
  72602. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72603. * @param parsedTexture defines parsed texture data
  72604. * @param scene defines the current scene
  72605. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72606. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72607. */
  72608. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72609. }
  72610. }
  72611. declare module BABYLON {
  72612. /** @hidden */
  72613. export var roadProceduralTexturePixelShader: {
  72614. name: string;
  72615. shader: string;
  72616. };
  72617. }
  72618. declare module BABYLON {
  72619. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72620. private _roadColor;
  72621. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72622. updateShaderUniforms(): void;
  72623. roadColor: BABYLON.Color3;
  72624. /**
  72625. * Serializes this road procedural texture
  72626. * @returns a serialized road procedural texture object
  72627. */
  72628. serialize(): any;
  72629. /**
  72630. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72631. * @param parsedTexture defines parsed texture data
  72632. * @param scene defines the current scene
  72633. * @param rootUrl defines the root URL containing road procedural texture information
  72634. * @returns a parsed Road Procedural BABYLON.Texture
  72635. */
  72636. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72637. }
  72638. }
  72639. declare module BABYLON {
  72640. /** @hidden */
  72641. export var starfieldProceduralTexturePixelShader: {
  72642. name: string;
  72643. shader: string;
  72644. };
  72645. }
  72646. declare module BABYLON {
  72647. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72648. private _time;
  72649. private _alpha;
  72650. private _beta;
  72651. private _zoom;
  72652. private _formuparam;
  72653. private _stepsize;
  72654. private _tile;
  72655. private _brightness;
  72656. private _darkmatter;
  72657. private _distfading;
  72658. private _saturation;
  72659. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72660. updateShaderUniforms(): void;
  72661. time: number;
  72662. alpha: number;
  72663. beta: number;
  72664. formuparam: number;
  72665. stepsize: number;
  72666. zoom: number;
  72667. tile: number;
  72668. brightness: number;
  72669. darkmatter: number;
  72670. distfading: number;
  72671. saturation: number;
  72672. /**
  72673. * Serializes this starfield procedural texture
  72674. * @returns a serialized starfield procedural texture object
  72675. */
  72676. serialize(): any;
  72677. /**
  72678. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72679. * @param parsedTexture defines parsed texture data
  72680. * @param scene defines the current scene
  72681. * @param rootUrl defines the root URL containing startfield procedural texture information
  72682. * @returns a parsed Starfield Procedural BABYLON.Texture
  72683. */
  72684. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72685. }
  72686. }
  72687. declare module BABYLON {
  72688. /** @hidden */
  72689. export var woodProceduralTexturePixelShader: {
  72690. name: string;
  72691. shader: string;
  72692. };
  72693. }
  72694. declare module BABYLON {
  72695. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72696. private _ampScale;
  72697. private _woodColor;
  72698. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72699. updateShaderUniforms(): void;
  72700. ampScale: number;
  72701. woodColor: BABYLON.Color3;
  72702. /**
  72703. * Serializes this wood procedural texture
  72704. * @returns a serialized wood procedural texture object
  72705. */
  72706. serialize(): any;
  72707. /**
  72708. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72709. * @param parsedTexture defines parsed texture data
  72710. * @param scene defines the current scene
  72711. * @param rootUrl defines the root URL containing wood procedural texture information
  72712. * @returns a parsed Wood Procedural BABYLON.Texture
  72713. */
  72714. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72715. }
  72716. }